The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Simulators >> Circuit Simulators >> exception handling in OCEAN
https://designers-guide.org/forum/YaBB.pl?num=1241807906

Message started by analogue_guy on May 8th, 2009, 11:38am

Title: exception handling in OCEAN
Post by analogue_guy on May 8th, 2009, 11:38am

Hi all,

Do you know how to make exception handling in Ocean?
If Calculator expressions, due to a reason, fail  (they result in NaN) usually stop the whole execution of the OCEAN script.
Any solution for that?

cheers

--AG

Title: Re: exception handling in OCEAN
Post by pancho_hideboo on May 8th, 2009, 9:44pm

Use "loadi()" instead of "load()".

Title: Re: exception handling in OCEAN
Post by Andrew Beckett on May 29th, 2009, 1:29am

The best solution is to check for return values of functions - for example, check that a data access function returned a value rather than nil - before using it in an expression.

That way you can handle errors gracefully rather than just causing an expression to fail. For example:


Code:
when(out=v("/out" ?result 'tran)
 fft=dft(out ...)
)


or:


Code:
if(out=v("/out" ?result 'tran) then
 fft=dft(out ...)
else
 printf("Transient analysis failed\n")
)


If for example the transient didn't run for some reason, v() will return nil, and so it won't try and do the dft on nil.

loadi() is one approach, but it's messy and doesn't really allow you to gracefully handle the errors.

Best Regards,

Andrew.

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.