projman/hlp/en/tcl/after.htm
2015-10-19 14:27:31 +04:00

115 lines
6.3 KiB
HTML

<HTML><HEAD><TITLE>Tcl Built-In Commands - after manual page</TITLE></HEAD><BODY>
<DL>
<DD><A HREF="after.htm#M2" NAME="L19">NAME</A>
<DL><DD>after - Execute a command after a time delay</DL>
<DD><A HREF="after.htm#M3" NAME="L20">SYNOPSIS</A>
<DL>
<DD><B>after </B><I>ms</I>
<DD><B>after </B><I>ms </I>?<I>script script script ...</I>?
<DD><B>after cancel </B><I>id</I>
<DD><B>after cancel </B><I>script script script ...</I>
<DD><B>after idle </B>?<I>script script script ...</I>?
<DD><B>after info </B>?<I>id</I>?
</DL>
<DD><A HREF="after.htm#M4" NAME="L21">DESCRIPTION</A>
<DL>
<DD><A HREF="after.htm#M5" NAME="L22"><B>after </B><I>ms</I></A>
<DD><A HREF="after.htm#M6" NAME="L23"><B>after </B><I>ms </I>?<I>script script script ...</I>?</A>
<DD><A HREF="after.htm#M7" NAME="L24"><B>after cancel </B><I>id</I></A>
<DD><A HREF="after.htm#M8" NAME="L25"><B>after cancel </B><I>script script ...</I></A>
<DD><A HREF="after.htm#M9" NAME="L26"><B>after idle </B><I>script </I>?<I>script script ...</I>?</A>
<DD><A HREF="after.htm#M10" NAME="L27"><B>after info </B>?<I>id</I>?</A>
</DL>
<DD><A HREF="after.htm#M11" NAME="L28">SEE ALSO</A>
<DD><A HREF="after.htm#M12" NAME="L29">KEYWORDS</A>
</DL><HR>
<H3><A NAME="M2">NAME</A></H3>
after - Execute a command after a time delay
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>after </B><I>ms</I><BR>
<B>after </B><I>ms </I>?<I>script script script ...</I>?<BR>
<B>after cancel </B><I>id</I><BR>
<B>after cancel </B><I>script script script ...</I><BR>
<B>after idle </B>?<I>script script script ...</I>?<BR>
<B>after info </B>?<I>id</I>?<BR>
<H3><A NAME="M4">DESCRIPTION</A></H3>
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:
<P>
<DL>
<P><DT><A NAME="M5"><B>after </B><I>ms</I></A><DD>
<I>Ms</I> must be an integer giving a time in milliseconds.
The command sleeps for <I>ms</I> milliseconds and then returns.
While the command is sleeping the application does not respond to
events.
<P><DT><A NAME="M6"><B>after </B><I>ms </I>?<I>script script script ...</I>?</A><DD>
In this form the command returns immediately, but it arranges
for a Tcl command to be executed <I>ms</I> 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 <I>script</I>
arguments in the same fashion as the <B><A HREF="../TkCmd/concat.htm">concat</A></B> command.
The command will be executed at global level (outside the context
of any Tcl procedure).
If an error occurs while executing the delayed command then the
<B><A HREF="../TkCmd/bgerror.htm">bgerror</A></B> mechanism is used to report the error.
The <B>after</B> command returns an identifier that can be used
to cancel the delayed command using <B>after cancel</B>.
<P><DT><A NAME="M7"><B>after cancel </B><I>id</I></A><DD>
Cancels the execution of a delayed command that
was previously scheduled.
<I>Id</I> indicates which command should be canceled; it must have
been the return value from a previous <B>after</B> command.
If the command given by <I>id</I> has already been executed then
the <B>after cancel</B> command has no effect.
<P><DT><A NAME="M8"><B>after cancel </B><I>script script ...</I></A><DD>
This command also cancels the execution of a delayed command.
The <I>script</I> arguments are concatenated together with space
separators (just as in the <B><A HREF="../TkCmd/concat.htm">concat</A></B> 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 <B>after cancel</B> command has no effect.
<P><DT><A NAME="M9"><B>after idle </B><I>script </I>?<I>script script ...</I>?</A><DD>
Concatenates the <I>script</I> arguments together with space
separators (just as in the <B><A HREF="../TkCmd/concat.htm">concat</A></B> 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 <B>after cancel</B>.
If an error occurs while executing the script then the
<B><A HREF="../TkCmd/bgerror.htm">bgerror</A></B> mechanism is used to report the error.
<P><DT><A NAME="M10"><B>after info </B>?<I>id</I>?</A><DD>
This command returns information about existing event handlers.
If no <I>id</I> argument is supplied, the command returns
a list of the identifiers for all existing
event handlers created by the <B>after</B> command for this
interpreter.
If <I>id</I> is supplied, it specifies an existing handler;
<I>id</I> must have been the return value from some previous call
to <B>after</B> and 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 associated
with <I>id</I>, and the second element is either
<B>idle</B> or <B>timer</B> to indicate what kind of event
handler it is.
<P></DL>
<P>
The <B>after </B><I>ms</I> and <B>after idle</B> forms of the command
assume that the application 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
<B><A HREF="../UserCmd/tclsh.htm">tclsh</A></B>, the event loop can be entered with the <B><A HREF="../TkCmd/vwait.htm">vwait</A></B>
and <B><A HREF="../TkCmd/update.htm">update</A></B> commands.
<H3><A NAME="M11">SEE ALSO</A></H3>
<B><A HREF="../TkCmd/bgerror.htm">bgerror</A></B>, <B><A HREF="../TkCmd/concat.htm">concat</A></B>, <B><A HREF="../TkCmd/update.htm">update</A></B>, <B><A HREF="../TkCmd/vwait.htm">vwait</A></B>
<H3><A NAME="M12">KEYWORDS</A></H3>
<A href="../Keywords/C.htm#cancel">cancel</A>, <A href="../Keywords/D.htm#delay">delay</A>, <A href="../Keywords/I.htm#idle callback">idle callback</A>, <A href="../Keywords/S.htm#sleep">sleep</A>, <A href="../Keywords/T.htm#time">time</A>
<HR><PRE>
<A HREF="../copyright.htm">Copyright</A> &#169; 1990-1994 The Regents of the University of California.
<A HREF="../copyright.htm">Copyright</A> &#169; 1994-1996 Sun Microsystems, Inc.
<A HREF="../copyright.htm">Copyright</A> &#169; 1995-1997 Roger E. Critchlow Jr.</PRE>
</BODY></HTML>