1mNAME0m
       after - Execute a command after a time delay

1mSYNOPSIS0m
       1mafter 4m22mms0m

       1mafter 4m22mms24m ?4mscript24m 4mscript24m 4mscript24m 4m...24m?

       1mafter cancel 4m22mid0m

       1mafter cancel 4m22mscript24m 4mscript24m 4mscript24m 4m...0m

       1mafter idle 22m?4mscript24m 4mscript24m 4mscript24m 4m...24m?

       1mafter info 22m?4mid24m?


1mDESCRIPTION0m
       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:

       1mafter 4m22mms0m
              4mMs24m  must  be an integer giving a time in milliseconds.  The com-
              mand sleeps for 4mms24m milliseconds and  then  returns.   While  the
              command  is sleeping the application does not respond to events.

       1mafter 4m22mms24m ?4mscript24m 4mscript24m 4mscript24m 4m...24m?
              In this form the command returns immediately,  but  it  arranges
              for  a  Tcl  command  to be executed 4mms24m milliseconds later as an
              event handler.  The command will be executed  exactly  once,  at
              the  given time.  The delayed command is formed by concatenating
              all the 4mscript24m arguments in the same fashion as the 1mconcat  22mcom-
              mand.  The command will be executed at global level (outside the
              context of any Tcl procedure).  If an error occurs while execut-
              ing  the  delayed  command then the 1mbgerror 22mmechanism is used to
              report the error.  The 1mafter 22mcommand returns an identifier  that
              can be used to cancel the delayed command using 1mafter cancel22m.

       1mafter cancel 4m22mid0m
              Cancels  the  execution of a delayed command that was previously
              scheduled.  4mId24m indicates which command should be  canceled;   it
              must  have  been the return value from a previous 1mafter 22mcommand.
              If the command given by 4mid24m has already been  executed  then  the
              1mafter cancel 22mcommand has no effect.

       1mafter cancel 4m22mscript24m 4mscript24m 4m...0m
              This  command  also  cancels the execution of a delayed command.
              The 4mscript24m arguments are concatenated together with space  sepa-
              rators  (just  as in the 1mconcat 22mcommand).  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
              1mafter cancel 22mcommand has no effect.

       1mafter idle 4m22mscript24m ?4mscript24m 4mscript24m 4m...24m?
              Concatenates the 4mscript24m arguments together with space separators
              (just  as in the 1mconcat 22mcommand), 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 1mafter cancel22m.  If an  error  occurs  while  executing  the
              script then the 1mbgerror 22mmechanism is used to report the error.

       1mafter info 22m?4mid24m?
              This  command returns information about existing event handlers.
              If no 4mid24m argument is supplied, the command returns a list of the
              identifiers for all existing event handlers created by the 1mafter0m
              command for this interpreter.  If 4mid24m is supplied,  it  specifies
              an  existing  handler;  4mid24m  must have been the return value from
              some previous call to 1mafter 22mand it must not have  triggered  yet
              or been cancelled.  In this case the command returns a list with
              two elements.  The first element of the list is the script asso-
              ciated  with  4mid24m, and the second element is either 1midle 22mor 1mtimer0m
              to indicate what kind of event handler it is.

       The 1mafter 4m22mms24m and 1mafter idle 22mforms 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 are
       not normally event-driven, such as 1mtclsh22m, the event loop can be entered
       with the 1mvwait 22mand 1mupdate 22mcommands.


1mSEE ALSO0m
       bgerror(n), concat(n), update(n), vwait(n)


1mKEYWORDS0m
