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, any
26       variables after the named one causing the error are  not  deleted.   An
27       error  can  occur  when  the named variable does not exist, or the name
28       refers to an array element but the variable is a scalar,  or  the  name
29       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              array set squares {
35                  1 1    6 36
36                  2 4    7 49
37                  3 9    8 64
38                  4 16   9 81
39                  5 25  10 100
40              }
41
42              puts "The squares are:"
43              parray squares
44
45              unset squares(1) squares(4) squares(6)
46              unset squares(8) squares(9) squares(10)
47
48              puts "The prime squares are:"
49              parray squares
50

SEE ALSO

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

KEYWORDS

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