"nan" v. try-catch for arithmetic
livfoss at mac.com
Tue Jun 24 14:02:56 EDT 2014
I have a bit of code that looks for input errors where the user is supposed to write an arithmetic expression into a field. The relevant fragment looks like this
put value(fld "myField") into testResult
answer "oops, that's not a valid real number. Try again"
Now I input a legitimate expression like 3+sin(pi/2)
the catch doesn't fire, as expected. If I put in something which isn't a well-formed expression, like
ardvaark + 92
it does fire, as expected. If I put
that fires too. But if I put
I get a result, "nan", and the catch doesn't fire. Why not? Maybe someone can explain what the engine is doing here - or is it just an obscure bug?
More information about the Use-livecode