80 lines
3.5 KiB
Plaintext
80 lines
3.5 KiB
Plaintext
'\"
|
|
'\" Copyright (c) 1993 The Regents of the University of California.
|
|
'\" All rights reserved.
|
|
'\"
|
|
'\" Permission is hereby granted, without written agreement and without
|
|
'\" license or royalty fees, to use, copy, modify, and distribute this
|
|
'\" documentation for any purpose, provided that the above copyright
|
|
'\" notice and the following two paragraphs appear in all copies.
|
|
'\"
|
|
'\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
|
|
'\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
'\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
|
|
'\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
'\"
|
|
'\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
|
'\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
'\" AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
'\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
|
|
'\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
'\"
|
|
'\" $Header: /user6/ouster/tcl/man/RCS/uplevel.n,v 1.1 93/06/16 16:48:27 ouster Exp $ SPRITE (Berkeley)
|
|
'\"
|
|
.so man.macros
|
|
.HS uplevel tcl
|
|
.BS
|
|
'\" Note: do not modify the .SH NAME line immediately below!
|
|
.SH NAME
|
|
uplevel \- Execute a script in a different stack frame
|
|
.SH SYNOPSIS
|
|
\fBuplevel \fR?\fIlevel\fR?\fI arg \fR?\fIarg ...\fR?
|
|
.BE
|
|
|
|
.SH DESCRIPTION
|
|
.PP
|
|
All of the \fIarg\fR arguments are concatenated as if they had
|
|
been passed to \fBconcat\fR; the result is then evaluated in the
|
|
variable context indicated by \fIlevel\fR. \fBUplevel\fR returns
|
|
the result of that evaluation.
|
|
.PP
|
|
If \fIlevel\fR is an integer then
|
|
it gives a distance (up the procedure calling stack) to move before
|
|
executing the command. If \fIlevel\fR consists of \fB#\fR followed by
|
|
a number then the number gives an absolute level number. If \fIlevel\fR
|
|
is omitted then it defaults to \fB1\fR. \fILevel\fR cannot be
|
|
defaulted if the first \fIcommand\fR argument starts with a digit or \fB#\fR.
|
|
.PP
|
|
For example, suppose that procedure \fBa\fR was invoked
|
|
from top-level, and that it called \fBb\fR, and that \fBb\fR called \fBc\fR.
|
|
Suppose that \fBc\fR invokes the \fBuplevel\fR command. If \fIlevel\fR
|
|
is \fB1\fR or \fB#2\fR or omitted, then the command will be executed
|
|
in the variable context of \fBb\fR. If \fIlevel\fR is \fB2\fR or \fB#1\fR
|
|
then the command will be executed in the variable context of \fBa\fR.
|
|
If \fIlevel\fR is \fB3\fR or \fB#0\fR then the command will be executed
|
|
at top-level (only global variables will be visible).
|
|
.PP
|
|
The \fBuplevel\fR command causes the invoking procedure to disappear
|
|
from the procedure calling stack while the command is being executed.
|
|
In the above example, suppose \fBc\fR invokes the command
|
|
.DS
|
|
\fBuplevel 1 {set x 43; d}
|
|
.DE
|
|
where \fBd\fR is another Tcl procedure. The \fBset\fR command will
|
|
modify the variable \fBx\fR in \fBb\fR's context, and \fBd\fR will execute
|
|
at level 3, as if called from \fBb\fR. If it in turn executes
|
|
the command
|
|
.DS
|
|
\fBuplevel {set x 42}
|
|
.DE
|
|
then the \fBset\fR command will modify the same variable \fBx\fR in \fBb\fR's
|
|
context: the procedure \fBc\fR does not appear to be on the call stack
|
|
when \fBd\fR is executing. The command ``\fBinfo level\fR'' may
|
|
be used to obtain the level of the current procedure.
|
|
.PP
|
|
\fBUplevel\fR makes it possible to implement new control
|
|
constructs as Tcl procedures (for example, \fBuplevel\fR could
|
|
be used to implement the \fBwhile\fR construct as a Tcl procedure).
|
|
|
|
.SH KEYWORDS
|
|
context, stack frame, variables
|