Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Tcl help: how do I identify a number?
In Tcl, how do I identify that a variable is a number? Or Char?
similiar to IsNumberic, or IsChar…
Thanks,
Sam 8)
Sam,
Check out ‘string is’.
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
Jim,
I guess I am lost, can you give me more detail of ‘string is’? an example?
Sam
The string Tcl command has many options. One of them is the ‘is class’ option. Do a help string in hcitcl to see all options etc.
example:
set junk abcdef
string is digit -strict $junk
—> returns a zero (not true)
set stuff 12345
string is digit -strict $stuff
—> returns a one (true)
set nonsense “”
string is digit -strict $nonsense
All the scenarios work except this case:
set ICD9 401.9
string is digit -strict $ICD9
—> returns zero
I tried the double para and it comes out good.
string is double $ICD9
Thanks for your help!!!