Tcl relational expression evaluation
When you are comparing values, the following hints may be useful:
- Tcl stores all values as strings, and will convert certain strings to numeric values when appropriate. If you want a literal to be treated as a numeric value, don't quote it.
if {[exa var_1] == 345}...
The following will also work: if {[exa var_1] == "345"}...
- However, if a literal cannot be represented as a number, you must quote it, or Tcl will give you an error. For instance:
if {[exa var_2] == 001Z}...
will give an error. if {[exa var_2] == "001Z"}...
will work okay. - Don't quote single characters in single quotes:
if {[exa var_3] == 'X'}...
will give an error if {[exa var_3] == "X"}...
will work okay. - For the equal operator, you must use the C operator "==" . For not-equal, you must use the C operator "!=".
Model Technology Incorporated Voice: (503) 641-1340 Fax: (503)526-5410 www.model.com sales@model.com |