I am trying to test to see if a user entered a valid number into a text editor. (Should be a dollar amount.) The procedure that is triggered is using nan( to check. But virtually everything I enter returns false. A string of text returns false.
nan is actually a floating point value. Functions like sqr(, log(, arcsin(, and arccos(, which are undefined for certain arguments, will return a nan value when given one of those arguments. The nan( function is looking for a value of nan or inf (infinity.) It will return true() for either of those two floating point values, and false() for everything else.
The val( function will return 0 if it can’t interpret the string as a number. If 0 is an acceptable entry, you may need to add a specific test for that. Maybe something like
?(val(theNumber)≠0 or theNumber BeginsWith "0",true(),false())
You can use a regular expression for this. Assume that VALUE is a variable containing text. If you want to find out if the text is a valid integer, use this formula:
_VALUE_ regexmatch {^(\+|-)?\d+$}
If you want to find out if the text is a valid floating point number, you could use this: