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
14

DESCRIPTION

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

EXAMPLE

33       Create an array containing a mapping from some numbers to their squares
34       and remove the array elements for non-prime numbers:
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
52

SEE ALSO

54       set(n), trace(n), upvar(n)
55
56

KEYWORDS

58       remove, variable
59
60
61
62Tcl                                   8.4                             unset(n)
Impressum