Cancel
Showing results for 
Search instead for 
Did you mean: 

Check if String is Numeric

Pioneer
Pioneer

Is there a way to check if a string is numeric?  (common function in may languages)

 

I have a table to change ProcTime based on MU Type, I'd like the user to be able to use more than just the "Constant" format, so the table column is string.  I would like to evaluate if the table value is 'numeric', and if so, I change the ProcTime to "constant", and if not, then I would set it to "Formula".

 

Or is there a better way to do this, that doesn't involve another table column specifying type.

 

Thanks,

DJH

2 REPLIES

Re: Check if String is Numeric

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

you can use the regex_search to look for letters
eg

var i:string:=tableFile[1,1]

if regex_search(i,"[^0-9.]") ="" then
   print str_to_num(i)
else
   print "text"
end

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Check if String is Numeric

Pioneer
Pioneer

Thanks. That should work.