2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 .TH set n "" Tcl "Tcl Built-In Commands"
13 '\" Note: do not modify the .SH NAME line immediately below!
15 set \- Read and write variables
17 \fBset \fIvarName \fR?\fIvalue\fR?
22 Returns the value of variable \fIvarName\fR.
23 If \fIvalue\fR is specified, then set
24 the value of \fIvarName\fR to \fIvalue\fR, creating a new variable
25 if one doesn't already exist, and return its value.
26 If \fIvarName\fR contains an open parenthesis and ends with a
27 close parenthesis, then it refers to an array element: the characters
28 before the first open parenthesis are the name of the array,
29 and the characters between the parentheses are the index within the array.
30 Otherwise \fIvarName\fR refers to a scalar variable.
31 Normally, \fIvarName\fR is unqualified
32 (does not include the names of any containing namespaces),
33 and the variable of that name in the current namespace is read or written.
34 If \fIvarName\fR includes namespace qualifiers
35 (in the array name if it refers to an array element),
36 the variable in the specified namespace is read or written.
38 If no procedure is active,
39 then \fIvarName\fR refers to a namespace variable
40 (global variable if the current namespace is the global namespace).
41 If a procedure is active, then \fIvarName\fR refers to a parameter
42 or local variable of the procedure unless the \fBglobal\fR command
43 was invoked to declare \fIvarName\fR to be global,
44 or unless a \fBvariable\fR command
45 was invoked to declare \fIvarName\fR to be a namespace variable.