Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert sleep for 30 seconds in tcl script?

Tags:

tcl

I want to insert sleep for 30 second in my TCL script.

I tried using sleep command. but its not working. could any one of you help on this?

like image 452
Kumar Avatar asked Aug 09 '14 14:08

Kumar


2 Answers

You have to use

after 30000

The argument to after is interpreted as milliseconds.
While asking a question, if you insert your code, that will be useful for others.

like image 81
rcubefather Avatar answered Oct 23 '22 08:10

rcubefather


As previously stated by Donal Fellows in the comments, rcubefather's solution will halt event processing while sleeping.

Here's a slightly different approach I use is:

after 30000 set stop_wait &
vwait stop_wait
unset stop_wait

This will put the 'after 30000' command in background (&) waiting for 'stop_wait' variable to be set, while any other event processing will not be halted. This behavior is much more evident working with Tk GUI. However this will not prevent 'vwait' command from catching up the variable when set, allowing this portion of code to proceed. Not CPU intensive as well.

like image 45
Losko Avatar answered Oct 23 '22 08:10

Losko