1unset(n)                     Tcl Built-In Commands                    unset(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       unset - Delete variables
9

SYNOPSIS

11       unset ?-nocomplain? ?--? ?name name name ...?
12______________________________________________________________________________
13

DESCRIPTION

15       This  command  removes  one or more variables.  Each name is a variable
16       name, specified in any of the ways acceptable to the set command.  If a
17       name  refers  to  an  element  of an array then that element is removed
18       without affecting the rest of the array.  If  a  name  consists  of  an
19       array  name  with  no  parenthesized  index,  then  the entire array is
20       deleted.  The unset command returns an  empty  string  as  result.   If
21       -nocomplain is specified as the first argument, any possible errors are
22       suppressed.  The option may not be  abbreviated,  in  order  to  disam‐
23       biguate  it  from possible variable names.  The option -- indicates the
24       end of the options, and should be used if you wish to remove a variable
25       with  the  same  name as any of the options.  If an error occurs during
26       variable deletion, any variables after the named one causing the  error
27       are  not  deleted.  An error can occur when the named variable does not
28       exist, or the name refers to an array element but  the  variable  is  a
29       scalar, or the name refers to a variable in a non-existent namespace.
30

EXAMPLE

32       Create an array containing a mapping from some numbers to their squares
33       and remove the array elements for non-prime numbers:
34
35              array set squares {
36                  1 1    6 36
37                  2 4    7 49
38                  3 9    8 64
39                  4 16   9 81
40                  5 25  10 100
41              }
42
43              puts "The squares are:"
44              parray squares
45
46              unset squares(1) squares(4) squares(6)
47              unset squares(8) squares(9) squares(10)
48
49              puts "The prime squares are:"
50              parray squares
51

SEE ALSO

53       set(n), trace(n), upvar(n)
54

KEYWORDS

56       remove, variable
57
58
59
60Tcl                                   8.4                             unset(n)
Impressum