#!/usr/bin/wish
# tester.tcl - test tcl constructs
# author : dave w capella http://grox.net/mailme
# date : Thu Mar 20 09:11:02 PDT 2008
############################################################
set ary { asdf qwer aaaaaaa }
set s $ary
join s " "
puts "s: $s"
exit
# hide window
wm withdraw .
# multi-line strings in double-quotes respect newlines
#
#puts "
#hello
#world
#"
# command line arg tests...
#
set timeout 40
puts "timeout: $timeout"
# print each arg
#
for {set x 0} { $x < $argc } { incr x } {
set s [ lindex $argv $x ]
puts $s
if { [string equal $s "-t"] } {
incr x
set timeout [ expr [ lindex $argv $x ] * 1000 ]
puts "timeout: $timeout"
}
}
# use of catch: exception processing
#
# bogus command. bad status code, no output.
set status [ catch { exec foo } result ]
puts "foo status: $status"
puts "foo result: $result"
#
# real command. status 0, outputs dir listing.
set dir "/tmp"
set status [ catch { exec ls $dir } result ]
puts "ls status: $status"
puts "ls result: $result"
if { [ file isfile "tst" ] == 0 } {
puts "tst is NOT a file"
exit 1
} else {
puts "tst is a file"
}
wm deiconify .
button .b -text start -textvariable btnvar -command {
if { $btnvar == "start" } {
set btnvar stop
} else {
set btnvar start
}
#.b configure -text stop
}
pack .b
# need explicit exit to break out of window mainloop
#exit