Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A way to intervene "after" in tcl

Tags:

tcl

I have written a tcl script where there is wait for 20 seconds in between. Sometimes I have to come out of the waiting (or rather stop ) in between. I have used: after 20000

Is there a way to stop the waiting?

like image 903
oak1208 Avatar asked Dec 12 '25 19:12

oak1208


1 Answers

If you just use:

after 20000

Then no, there's no way (other than killing the process with Ctrl+C or kill, of course).

If you want an interruptable wait in Tcl, use this:

after 20000 set done 1
vwait done

That will continue to service events and so can be interrupted. Save the token returned by after 20000 set done 1 and you can cancel the timer (e.g., if you want to reschedule it). Set the (global done) variable yourself otherwise and you'll finish waiting sooner.

like image 70
Donal Fellows Avatar answered Dec 14 '25 07:12

Donal Fellows



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!