Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

after command

Status
Not open for further replies.

691220

Technical User
Apr 1, 2005
1
US
I am trying to execute a command after a specific time period using the "after" command.
I say : after $delay [list command].

I give this inside a tcl procedure. When I call the procedure the line that has the after command is not executed. However if I just give:
after $delay
the delay is incorporated.

Please let me know the reason for this or if there is any other alternative for this.

Thanks,
Harish.
 
I noticed this behavior, too. I don't think it hurts anything, though. Just put the command you want to execute after the delay after the "after" line.

_________________
Bob Rashkin
rrashkin@csc.com
 
Big difference in using after from within the event loop and outside of it, blocking and non-blocking to start. At least I'm inferring that this is the problem.
Try the difference between the following two snippets:

Code:
proc fooret {val} {
                  if {$val < 12} {puts "Value = $val -- Waiting  2 sec and then incrementing $val"; after 2000 [list eval fooret [expr $val + 1]]}
		  if {$val == 12} {puts "Ending proggie after 2 seconds"; after 2000 [list uplevel #0 "set forever 1"]}
		  puts "At end of execution..waiting for return"
}
fooret 1
vwait forever

2.
Code:
proc fooret {val} {
                  if {$val < 12} {puts "Value = $val -- Waiting  2 sec and then incrementing $val"; after 2000 [list eval fooret [expr $val + 1]]}
		  if {$val == 12} {puts "Ending proggie after 2 seconds"; after 2000 [list uplevel #0 "set forever 1"]}
		  puts "At end of execution..waiting for return"
}
fooret 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top