NAME
after - Execute a command after a time delay
SYNOPSIS
aafftteerr ms aafftteerr ms ?script script script ...? aafftteerr ccaanncceell id aafftteerr ccaanncceell script script script ... aafftteerr iiddllee ?script script script ...? aafftteerr iinnffoo ?id?DESCRIPTION
This command is used to delay execution of the program or to execute a command in background sometime in the future. It has several forms, depending on the first argument to the command: aafftteerr msMs must be an integer giving a time in milliseconds. The com-
mand sleeps for ms milliseconds and then returns. While the command is sleeping the application does not respond to events. aafftteerr ms ?script script script ...? In this form the command returns immediately, but it arranges for a Tcl command to be executed ms milliseconds later as an event handler. The command will be executed exactly once, at the given time. The delayed command is formed by concatenatingall the script arguments in the same fashion as the ccoonnccaatt com-
mand. The command will be executed at global level (outside thecontext of any Tcl procedure). If an error occurs while execut-
ing the delayed command then the bbggeerrrroorr mechanism is used to report the error. The aafftteerr command returns an identifier that can be used to cancel the delayed command using aafftteerr ccaanncceell. aafftteerr ccaanncceell id Cancels the execution of a delayed command that was previously scheduled. Id indicates which command should be canceled; it must have been the return value from a previous aafftteerr command. If the command given by id has already been executed then the aafftteerr ccaanncceell command has no effect. aafftteerr ccaanncceell script script ... This command also cancels the execution of a delayed command.The script arguments are concatenated together with space sepa-
rators (just as in the ccoonnccaatt command). If there is a pending command that matches the string, it is cancelled and will never be executed; if no such command is currently pending then the aafftteerr ccaanncceell command has no effect. aafftteerr iiddllee script ?script script ...? Concatenates the script arguments together with space separators (just as in the ccoonnccaatt command), and arranges for the resulting script to be evaluated later as an idle callback. The script will be run exactly once, the next time the event loop is entered and there are no events to process. The command returns an identifier that can be used to cancel the delayed command using aafftteerr ccaanncceell. If an error occurs while executing the script then the bbggeerrrroorr mechanism is used to report the error. aafftteerr iinnffoo ?id? This command returns information about existing event handlers. If no id argument is supplied, the command returns a list of the identifiers for all existing event handlers created by the aafftteerr command for this interpreter. If id is supplied, it specifies an existing handler; id must have been the return value from some previous call to aafftteerr and it must not have triggered yet or been cancelled. In this case the command returns a list withtwo elements. The first element of the list is the script asso-
ciated with id, and the second element is either iiddllee or ttiimmeerr to indicate what kind of event handler it is.The aafftteerr ms and aafftteerr iiddllee forms of the command assume that the appli-
cation is event driven: the delayed commands will not be executed unless the application enters the event loop. In applications that arenot normally event-driven, such as ttccllsshh, the event loop can be entered
with the vvwwaaiitt and uuppddaattee commands.SEE ALSO
bgerror(n), concat(n), update(n), vwait(n) KKEEYYWWOORRDDSS cancel, delay, idle callback, sleep, timeTcl 7.5 after(n)