1mNAME0m
       uplevel - Execute a script in a different stack frame

1mSYNOPSIS0m
       1muplevel 22m?4mlevel24m? 4marg24m ?4marg24m 4m...24m?


1mDESCRIPTION0m
       All of the 4marg24m arguments are concatenated as if they had been passed to
       1mconcat22m; the result is then evaluated in the variable context  indicated
       by 4mlevel24m.  1mUplevel 22mreturns the result of that evaluation.

       If 4mlevel24m is an integer then it gives a distance (up the procedure call-
       ing stack) to move before executing the command.  If 4mlevel24m consists  of
       1m#  22mfollowed by a number then the number gives an absolute level number.
       If 4mlevel24m is omitted then it defaults to 1m122m.  4mLevel24m cannot  be  defaulted
       if the first 4mcommand24m argument starts with a digit or 1m#22m.

       For  example,  suppose that procedure 1ma 22mwas invoked from top-level, and
       that it called 1mb22m, and that 1mb 22mcalled 1mc22m.   Suppose  that  1mc  22minvokes  the
       1muplevel  22mcommand.   If  4mlevel24m  is 1m1 22mor 1m#2  22mor omitted, then the command
       will be executed in the variable context of 1mb22m.  If 4mlevel24m  is  1m2  22mor  1m#10m
       then  the  command  will  be executed in the variable context of 1ma22m.  If
       4mlevel24m is 1m3 22mor 1m#0 22mthen the command will be executed at  top-level  (only
       global variables will be visible).

       The 1muplevel 22mcommand causes the invoking procedure to disappear from the
       procedure calling stack while the command is being  executed.   In  the
       above example, suppose 1mc 22minvokes the command
              1muplevel 1 {set x 43; d}0m
       where  1md  22mis  another  Tcl  procedure.  The 1mset 22mcommand will modify the
       variable 1mx 22min 1mb22m's context, and 1md 22mwill execute at level 3, as if  called
       from 1mb22m.  If it in turn executes the command
              1muplevel {set x 42}0m
       then  the  1mset  22mcommand will modify the same variable 1mx 22min 1mb22m's context:
       the procedure 1mc 22mdoes not appear to be on the call stack when 1md 22mis  exe-
       cuting.   The command ``1minfo level22m'' may be used to obtain the level of
       the current procedure.

       1mUplevel 22mmakes it possible to implement new control  constructs  as  Tcl
       procedures  (for  example, 1muplevel 22mcould be used to implement the 1mwhile0m
       construct as a Tcl procedure).

       1mnamespace eval 22mis another way (besides procedure calls)  that  the  Tcl
       naming context can change.  It adds a call frame to the stack to repre-
       sent the namespace context.  This means  each  1mnamespace  eval  22mcommand
       counts as another call level for 1muplevel 22mand 1mupvar 22mcommands.  For exam-
       ple, 1minfo level 1 22mwill return a  list  describing  a  command  that  is
       either  the  outermost  procedure  call or the outermost 1mnamespace eval0m
       command.  Also, 1muplevel #0 22mevaluates a script at top-level in the  out-
       ermost namespace (the global namespace).


1mSEE ALSO0m
       namespace(n), upvar(n)


1mKEYWORDS0m
