This manual page is for Mac OS X version 10.6.3

If you are running a different version of Mac OS X, view the documentation locally:

  • In Terminal, using the man(1) command

Reading manual pages

Manual pages are intended as a quick reference for people who already understand a technology.

  • For more information about the manual page format, see the manual page for manpages(5).

  • For more information about this technology, look for other documentation in the Apple Reference Library.

  • For general information about writing shell scripts, read Shell Scripting Primer.



set(n)                                      Tcl Built-In Commands                                     set(n)



____________________________________________________________________________________________________________

NAME
       set - Read and write variables

SYNOPSIS
       set varName ?value?
____________________________________________________________________________________________________________

DESCRIPTION
       Returns  the  value  of  variable  varName.   If value is specified, then set the value of varName to
       value, creating a new variable if one does not already exist, and return its value.  If varName  con-tains contains
       tains an open parenthesis and ends with a close parenthesis, then it refers to an array element:  the
       characters before the first open parenthesis are the name of the array, and  the  characters  between
       the parentheses are the index within the array.  Otherwise varName refers to a scalar variable.

       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.

EXAMPLES
       Store a random number in the variable r:
              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]

SEE ALSO
       expr(n), global(n), namespace(n), proc(n), trace(n), unset(n), upvar(n), variable(n)

KEYWORDS
       read, write, variable



Tcl                                                                                                   set(n)

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors
Report errors in the content of this documentation to the Tcl project.
Bug reports
Report bugs in the functionality of the described tool or API to Apple through Bug Reporter and to the Tcl project through their bug reporting page.
Formatting problems
Report formatting mistakes in the online version of these pages with the feedback links below.

Did this document help you? Yes It's good, but... Not helpful...