On Sep 30, 2006, at 12:56 PM, Francis Nugent Dixon wrote:

I want to check the contents of a field for numeric,
so, for a field of four characters, I coded :

 matchText(field MyTextField,"[0-9][0-9][0-9][0-9]")
 if it is true then ......

Is this the right way to check for numerics, and if
so, what have I done wrong ?

Revolution defines matchText as a function. The above script will look for a command named matchText. (An implied 'get' does sound like an interesting idea.)

So, first of all, change the above to this:

   get matchText(field MyTextField,"[0-9][0-9][0-9][0-9]")
   if it is true then ......

This is also OK, if you are content with the readability:

   get matchText(field MyTextField,"[0-9][0-9][0-9][0-9]")
   if it then ......

Or this:

   if matchText(field MyTextField,"[0-9][0-9][0-9][0-9]") then ......

That will match text that contains 4 digits in a row and so will match "around 1966 or so" or "4/5/1966". Perhaps this does what you want:

   if matchText(field MyTextField,"\A[0-9]{4}\z") then ......

The \A and \z match at the start and end respectively. The {4} means exactly 4 times.

You might want to consider "is a number".  Use it like this:

   if field MyTextField is a number then ......

That will match some numerals that you might not expect, such as "1.3", "1.0E01", "+inf" (on OS X) and "0xF0E".
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to