home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / u_man / cat3 / Tcl / proc.z / proc
Encoding:
Text File  |  1998-10-30  |  3.4 KB  |  67 lines

  1.  
  2.  
  3.  
  4. pppprrrroooocccc((((3333TTTTccccllll))))                                                          pppprrrroooocccc((((3333TTTTccccllll))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      proc - Create a Tcl procedure
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      pppprrrroooocccc _n_a_m_e _a_r_g_s _b_o_d_y
  13.  
  14.  
  15. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  16.      The pppprrrroooocccc command creates a new Tcl procedure named _n_a_m_e, replacing any
  17.      existing command or procedure there may have been by that name.  Whenever
  18.      the new command is invoked, the contents of _b_o_d_y will be executed by the
  19.      Tcl interpreter.  _A_r_g_s specifies the formal arguments to the procedure.
  20.      It consists of a list, possibly empty, each of whose elements specifies
  21.      one argument.  Each argument specifier is also a list with either one or
  22.      two fields.  If there is only a single field in the specifier then it is
  23.      the name of the argument; if there are two fields, then the first is the
  24.      argument name and the second is its default value.
  25.  
  26.      When _n_a_m_e is invoked a local variable will be created for each of the
  27.      formal arguments to the procedure; its value will be the value of
  28.      corresponding argument in the invoking command or the argument's default
  29.      value.  Arguments with default values need not be specified in a
  30.      procedure invocation.  However, there must be enough actual arguments for
  31.      all the formal arguments that don't have defaults, and there must not be
  32.      any extra actual arguments.  There is one special case to permit
  33.      procedures with variable numbers of arguments.  If the last formal
  34.      argument has the name aaaarrrrggggssss, then a call to the procedure may contain more
  35.      actual arguments than the procedure has formals.  In this case, all of
  36.      the actual arguments starting at the one that would be assigned to aaaarrrrggggssss
  37.      are combined into a list (as if the lllliiiisssstttt command had been used); this
  38.      combined value is assigned to the local variable aaaarrrrggggssss.
  39.  
  40.      When _b_o_d_y is being executed, variable names normally refer to local
  41.      variables, which are created automatically when referenced and deleted
  42.      when the procedure returns.  One local variable is automatically created
  43.      for each of the procedure's arguments.  Global variables can only be
  44.      accessed by invoking the gggglllloooobbbbaaaallll command or the uuuuppppvvvvaaaarrrr command.
  45.  
  46.      The pppprrrroooocccc command returns an empty string.  When a procedure is invoked,
  47.      the procedure's return value is the value specified in a rrrreeeettttuuuurrrrnnnn command.
  48.      If the procedure doesn't execute an explicit rrrreeeettttuuuurrrrnnnn, then its return
  49.      value is the value of the last command executed in the procedure's body.
  50.      If an error occurs while executing the procedure body, then the
  51.      procedure-as-a-whole will return that same error.
  52.  
  53.  
  54. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  55.      argument, procedure
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.