mercredi 31 décembre 2014

Treat argument as string in Tcl 'expr' statement

I'm using the short syntax of 'if' statement like this:



set Value 4E20 ;# Merely hexadecimal number
set Selector Second ;# Just for the example
set Data [expr {$Selector eq "First" ? 1234 : $Value}]
puts $Data


The problem is that since the 'expr' statement always treats its arguments as integers, 'Data' gets the value of 4e+20, which is merely the scientific notation of 'Value'.


However, I need 'Data' to be 'Value' (for example, to write to an external register).


Any ideas?


Aucun commentaire:

Enregistrer un commentaire