home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
dirs
/
tcl_447.lzh
/
TCL
/
tcl.lzh
/
tcl
/
help
/
uplevel
< prev
next >
Wrap
Text File
|
1990-05-03
|
2KB
|
39 lines
uplevel level command command ...
All of the command arguments are concatenated as if
they had been passed to concat and the result is
evaluated in the variable context indicated by level.
Uplevel returns the result of that evaluation. If
level is zero, then top-level context is used (all
variable names refer to global variables). If level is
a positive number, then it is treated as a stack level:
1 refers to the topmost active procedure, 2 to the
procedure it called, and so on. If level is a negative
number, then it is treated as a level relative to the
current procedure. For example, a level of -1 refers
to the procedure that called the one invoking the
uplevel command (which is top-level if the procedure
invoking uplevel is at level 1). The uplevel command
causes the invoking procedure to disappear from the
procedure calling stack while the command is being
executed. For example, suppose procedure x is at level
3 and invokes the command
uplevel -1 {set a 43; c}
where c is another Tcl procedure. The set command will
modify variable a in x's caller, and c will execute at
level 3, as if called from x's caller. If it in turn
executes the command
uplevel -1 {set a 42}
then the set command will modify the same variable a in
x's caller: the procedure x does not appear to be on
the call stack when c is executing. The command ``info
level'' may be used to obtain the level of the current
procedure. Uplevel makes it possible to implement new
control constructs as Tcl procedures (for example,
uplevel could be used to implement the while construct
as a Tcl procedure).