This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1 @@
after 1000 {myroutine x}

View file

@ -0,0 +1 @@
after cancel myroutine

View file

@ -0,0 +1,8 @@
package require Tk
proc update {} {
.clockface configure -text [clock format [clock seconds]]
after 1000 update ; # call yourself in a second
}
# now just create the 'clockface' and call ;update' once:
pack [label .clockface]
update

View file

@ -0,0 +1,5 @@
if {[catch { ''... code that might give error ...'' } result]} {
puts "Error was $result"
} else {
''... process $result ...''
}

View file

@ -0,0 +1,10 @@
try {
# Just a silly example...
set f [open $filename]
expr 1/0
string length [read $f]
} trap {ARITH DIVZERO} {} {
puts "divided by zero"
} finally {
close $f
}

View file

@ -0,0 +1,8 @@
proc forfilelines {linevar filename code} {
upvar $linevar line ; # connect local variable line to caller's variable
set filechan [open $filename]
while {[gets $filechan line] != -1} {
uplevel 1 $code ; # Run supplied code in caller's scope
}
close $filechan
}

View file

@ -0,0 +1,3 @@
forfilelines myline mydata.txt {
puts [string length $myline]
}