Menu

after command in tcl

Using after command like this :

after $period {set ::x_wait 1}
vwait ::x_wait

coupled with a bound event like this :
bind all <Key-Down> {go_down}

proc go_down {} {
set ::x_wait 1
}

will lead the periodic program to be disturbed with the remaining after timer, because the vwait has been unlocked by the event and not by the after.

The solution is :

set id [after $period {set ::x_wait 1}]
vwait ::x_wait
after cancel $id

Simple, but it took me quite a while to discover it !

Posted by Didier Provost 2004-10-12

Log in to post a comment.