|
|
TopPage > Tcl関係[00] > Tcl関係[01] |
[hoge user]$ tclsh % expr 1==1 1 % expr 1==2 0 |
False | True | |
a numeric value | 0 | all others |
yes/no | no | yes |
true/false | false | true |
#!/usr/bin/tclsh set abc 2 expr { $abc >= 0 ? [puts "TRUE"] : [puts "FALSE"] } set abc -2 expr { $abc >= 0 ? [puts "TRUE"] : [puts "FALSE"] } exit |
[hoge user]$ chmod u+x ./sample03.tcl [hoge user]$ ./sample03.tcl TRUE FALSE [hoge user]$ |
#!/usr/bin/tclsh set abc 2 if { $abc >= 0 } { puts "TRUE" } else { puts "FALSE" } set abc -2 if { $abc >= 0 } { puts "TRUE" } else { puts "FALSE" } exit |
[hoge user]$ chmod u+x ./sample04.tcl [hoge user]$ ./sample04.tcl TRUE FALSE [hoge user]$ |
#!/usr/bin/tclsh set abc 2 if{ $abc >= 0 } { puts "TRUE" } else { puts "FALSE" } set abc -2 if { $abc >= 0 } { puts "TRUE" } else { puts "FALSE" } exit |
[hoge user]$ chmod u+x ./sample04err.tcl [hoge user]$ ./sample04err.tcl invalid command name "if{" while executing "if{ $abc >= 0 } { puts "TRUE" } else { puts "FALSE" }" (file "./sample04err.tcl" line 3) [hoge user]$ |
TopPage > Tcl関係[00] > Tcl関係[01] |