Testing for numerics
FlexibleLearning at aol.com
FlexibleLearning at aol.com
Wed Oct 4 13:13:30 EDT 2006
Overkill solution...
function isPositiveInteger pValue
replace comma with empty in pValue # Thousands separator
replace "$" with empty in pValue # Currency identifier
try
add 1 to pValue
catch errnum
return "false" # Not a number
end try
if trunc(pValue) <> pValue then return "false" # Not an Integer
return pValue >= 1 # Is not negative
end isPositiveInteger
Underkill solution...
function isPositiveInteger pValue
return (pValue is a number) AND (pValue >=0) AND (trunc(pValue)=pValue)
end isPositiveInteger
/H
More information about the use-livecode
mailing list