OSDN Git Service

3d51b4af16dd7499499e4e414358035c86eec900
[pf3gnuchains/sourceware.git] / tcl / doc / after.n
1 '\"
2 '\" Copyright (c) 1990-1994 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\" 
8 '\" RCS: @(#) $Id$
9 '\" 
10 .so man.macros
11 .TH after n 7.5 Tcl "Tcl Built-In Commands"
12 .BS
13 '\" Note:  do not modify the .SH NAME line immediately below!
14 .SH NAME
15 after \- Execute a command after a time delay
16 .SH SYNOPSIS
17 \fBafter \fIms\fR
18 .sp
19 \fBafter \fIms \fR?\fIscript script script ...\fR?
20 .sp
21 \fBafter cancel \fIid\fR
22 .sp
23 \fBafter cancel \fIscript script script ...\fR
24 .sp
25 \fBafter idle \fR?\fIscript script script ...\fR?
26 .sp
27 \fBafter info \fR?\fIid\fR?
28 .BE
29
30 .SH DESCRIPTION
31 .PP
32 This command is used to delay execution of the program or to execute
33 a command in background sometime in the future.  It has several forms,
34 depending on the first argument to the command:
35 .TP
36 \fBafter \fIms\fR
37 \fIMs\fR must be an integer giving a time in milliseconds.
38 The command sleeps for \fIms\fR milliseconds and then returns.
39 While the command is sleeping the application does not respond to
40 events.
41 .TP
42 \fBafter \fIms \fR?\fIscript script script ...\fR?
43 In this form the command returns immediately, but it arranges
44 for a Tcl command to be executed \fIms\fR milliseconds later as an
45 event handler.
46 The command will be executed exactly once, at the given time.
47 The delayed command is formed by concatenating all the \fIscript\fR
48 arguments in the same fashion as the \fBconcat\fR command.
49 The command will be executed at global level (outside the context
50 of any Tcl procedure).
51 If an error occurs while executing the delayed command then the
52 \fBbgerror\fR mechanism is used to report the error.
53 The \fBafter\fR command returns an identifier that can be used
54 to cancel the delayed command using \fBafter cancel\fR.
55 .TP
56 \fBafter cancel \fIid\fR
57 Cancels the execution of a delayed command that
58 was previously scheduled.
59 \fIId\fR indicates which command should be canceled;  it must have
60 been the return value from a previous \fBafter\fR command.
61 If the command given by \fIid\fR has already been executed then
62 the \fBafter cancel\fR command has no effect.
63 .TP
64 \fBafter cancel \fIscript script ...\fR
65 This command also cancels the execution of a delayed command.
66 The \fIscript\fR arguments are concatenated together with space
67 separators (just as in the \fBconcat\fR command).
68 If there is a pending command that matches the string, it is
69 cancelled and will never be executed;  if no such command is
70 currently pending then the \fBafter cancel\fR command has no effect.
71 .TP
72 \fBafter idle \fIscript \fR?\fIscript script ...\fR?
73 Concatenates the \fIscript\fR arguments together with space
74 separators (just as in the \fBconcat\fR command), and arranges
75 for the resulting script to be evaluated later as an idle callback.
76 The script will be run exactly once, the next time the event
77 loop is entered and there are no events to process.
78 The command returns an identifier that can be used
79 to cancel the delayed command using \fBafter cancel\fR.
80 If an error occurs while executing the script then the
81 \fBbgerror\fR mechanism is used to report the error.
82 .TP
83 \fBafter info \fR?\fIid\fR?
84 This command returns information about existing event handlers.
85 If no \fIid\fR argument is supplied, the command returns
86 a list of the identifiers for all existing
87 event handlers created by the \fBafter\fR command for this
88 interpreter.
89 If \fIid\fR is supplied, it specifies an existing handler;
90 \fIid\fR must have been the return value from some previous call
91 to \fBafter\fR and it must not have triggered yet or been cancelled.
92 In this case the command returns a list with two elements.
93 The first element of the list is the script associated
94 with \fIid\fR, and the second element is either
95 \fBidle\fR or \fBtimer\fR to indicate what kind of event
96 handler it is.
97 .LP
98 The \fBafter \fIms\fR and \fBafter idle\fR forms of the command
99 assume that the application is event driven:  the delayed commands
100 will not be executed unless the application enters the event loop.
101 In applications that are not normally event-driven, such as
102 \fBtclsh\fR, the event loop can be entered with the \fBvwait\fR
103 and \fBupdate\fR commands.
104
105 .SH "SEE ALSO"
106 bgerror
107
108 .SH KEYWORDS
109 cancel, delay, idle callback, sleep, time