home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / tcl / tcl_1 / !Tcl_library_env < prev    next >
Encoding:
Text File  |  1994-09-25  |  531 b   |  26 lines

  1. # env - provides the system variable array env
  2.  
  3. # The trace mechanism cannot cope with unsetting an env variable that has
  4. # not yet been read.
  5. # use "set env(x) {}" instead of "unset env(x)"
  6.  
  7. set env(1) ""
  8. trace variable env rwu env_proc
  9.  
  10. proc env_proc {name element op}\
  11.  {
  12.    if {$element!=""}\
  13.    { set name ${name}($element)
  14.      upvar $name x
  15.      switch $op\
  16.      { r { set x [getenv $element] ; return $x}
  17.        w { system "set $element \"$x\""; return $x }
  18.        u { system "unset $element" ; return }
  19.      }
  20.    }
  21.  }
  22.  
  23.  
  24.  
  25.  
  26.