If varName includes namespace qualifiers (in the array name if it refers to an array element), or if varName is unqualified (does not include the names of any containing namespaces) but no procedure is active, varName refers to a namespace variable resolved according to the rules described under NAME RESOLUTION in the namespace manual page.
If a procedure is active and varName is unqualified, then varName refers to a parameter or local variable of the procedure, unless varName was declared to resolve differently through one of the global, variable or upvar commands.
set r [expr {rand()}]
Store a short message in an array element:
set anAry(msg) "Hello, World!"
Store a short message in an array element specified by a variable:
set elemName "msg" set anAry($elemName) "Hello, World!"
Copy a value into the variable out from a variable whose name is stored in the vbl (note that it is often easier to use arrays in practice instead of doing double-dereferencing):
set in0 "small random" set in1 "large random" set vbl in[expr {rand() >= 0.5}] set out [set $vbl]
Copyright © 1993 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.
Licensed under Tcl/Tk terms
https://www.tcl.tk/man/tcl/TclCmd/set.htm