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 >
Text File  |  1990-05-03  |  2KB  |  39 lines

  1.  uplevel level command command ...
  2.       All of the command arguments are concatenated as if 
  3.       they had been passed to concat and the result is  
  4.       evaluated in the variable context indicated by level. 
  5.       Uplevel returns the result of that evaluation.  If 
  6.       level is zero, then top-level context is used (all 
  7.       variable names refer to global variables).  If level is 
  8.       a positive number, then it is treated as a stack level: 
  9.       1 refers to the topmost active procedure, 2 to the 
  10.       procedure it called, and so on. If level is a negative 
  11.       number, then it is treated as a level relative to the 
  12.       current procedure.  For example, a level of -1 refers 
  13.       to the procedure that called the one invoking the 
  14.       uplevel command (which is top-level if the procedure 
  15.       invoking uplevel is at level 1).  The uplevel command 
  16.       causes the invoking procedure to disappear from the 
  17.       procedure calling stack while the command is being 
  18.       executed.  For example, suppose procedure x is at level 
  19.       3 and invokes the command    
  20.  
  21.       uplevel -1 {set a 43; c}     
  22.  
  23.       where c is another Tcl procedure.  The set command will 
  24.       modify variable a in x's caller, and c will execute at 
  25.       level 3, as if called from x's caller.  If it in turn 
  26.       executes the command     
  27.  
  28.       uplevel -1 {set a 42}     
  29.  
  30.       then the set command will modify the same variable a in 
  31.       x's caller:  the procedure x does not appear to be on 
  32.       the call stack when c is executing.  The command ``info 
  33.       level'' may be used to obtain the level of the current 
  34.       procedure.  Uplevel makes it possible to implement new 
  35.       control constructs as Tcl procedures (for example, 
  36.       uplevel could be used to implement the while construct 
  37.       as a Tcl procedure).
  38.  
  39.