tcl - When i am executing it it says can't read s0 not such variable. Please -


proc ok { } { exec echo "list of tokens requested killed user" >killed_file; #the information dumped in file named killed_file     global s0 s1 s2 s3 s4 s5     if {$s0} {exec echo "$s0 choice a" >>killed_file}     if {$s1} {exec echo "$s1 choice b" >>killed_file}     if {$s2} {exec echo "$s2 choice c" >>killed_file}     if {$s3} {exec echo "$s3 choice d" >>killed_file}     if {$s4} {exec echo "$s4 choice e" >>killed_file}     if {$s5} {exec echo "$s5 choice f" >>killed_file} destroy .top } 

executing says can't read s0 no such variable , same other variables.

presumably variables s0 s5 have not been set.

if want skip them when not exists can use command info exists name test this. using strange method write file. more straightforward alternative (not tested) be:

proc ok { } {     #the information dumped in file named killed_file     set kf [open killed_file w]     puts $kf "list of tokens requested killed user"     global s0 s1 s2 s3 s4 s5     if {[info exists s0]} {puts $kf "$s0 choice a"}     if {[info exists s1]} {puts $kf "$s1 choice b"}     if {[info exists s2]} {puts $kf "$s2 choice c"}     if {[info exists s3]} {puts $kf "$s3 choice d"}     if {[info exists s4]} {puts $kf "$s4 choice e"}     if {[info exists s5]} {puts $kf "$s5 choice f"}     close $kf     destroy .top } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -