[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] String problem



On Thu, 27 Sep 2001, Michael Gao wrote:

> Why there alwasy an erro when I use the following if
> statement.
> "set name [lindex $argv 0]
> if {[expr name == "Tahoe"] } {
>     set name " "
> }"
> Error:
> syntax error in expression "name == Tahoe"
>     while executing
> "expr name == "Tahoe""

if {[expr $name] == "Tahoe"} {
          ^

if {$name == "Tahoe"} {
    ^
makes more sense, since there's nothing fancy in just $name
that really requires the use of expr.

> while there is no such problem when I use 
> if {[expr number == 1] } {
>     set name 2
> }

that probably evaluates to zero... you might want to try reading a
book on Tcl.

L.

<[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>