| 1 |
'\" |
| 2 |
'\" Copyright (c) 1993 The Regents of the University of California. |
| 3 |
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 4 |
'\" Copyright (c) 2000 Ajuba Solutions. |
| 5 |
'\" |
| 6 |
'\" See the file "license.terms" for information on usage and redistribution |
| 7 |
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 8 |
'\" |
| 9 |
.TH unset n 8.4 Tcl "Tcl Built-In Commands" |
| 10 |
.so man.macros |
| 11 |
.BS |
| 12 |
'\" Note: do not modify the .SH NAME line immediately below! |
| 13 |
.SH NAME |
| 14 |
unset \- Delete variables |
| 15 |
.SH SYNOPSIS |
| 16 |
\fBunset \fR?\fB\-nocomplain\fR? ?\fB\-\-\fR? ?\fIname name name ...\fR? |
| 17 |
.BE |
| 18 |
.SH DESCRIPTION |
| 19 |
.PP |
| 20 |
This command removes one or more variables. |
| 21 |
Each \fIname\fR is a variable name, specified in any of the |
| 22 |
ways acceptable to the \fBset\fR command. |
| 23 |
If a \fIname\fR refers to an element of an array then that |
| 24 |
element is removed without affecting the rest of the array. |
| 25 |
If a \fIname\fR consists of an array name with no parenthesized |
| 26 |
index, then the entire array is deleted. |
| 27 |
The \fBunset\fR command returns an empty string as result. |
| 28 |
If \fB\-nocomplain\fR is specified as the first argument, any possible |
| 29 |
errors are suppressed. The option may not be abbreviated, in order to |
| 30 |
disambiguate it from possible variable names. The option \fB\-\-\fR |
| 31 |
indicates the end of the options, and should be used if you wish to |
| 32 |
remove a variable with the same name as any of the options. |
| 33 |
If an error occurs during variable deletion, any variables after the named one |
| 34 |
causing the error are not |
| 35 |
deleted. An error can occur when the named variable does not exist, or the |
| 36 |
name refers to an array element but the variable is a scalar, or the name |
| 37 |
refers to a variable in a non-existent namespace. |
| 38 |
.SH EXAMPLE |
| 39 |
.PP |
| 40 |
Create an array containing a mapping from some numbers to their |
| 41 |
squares and remove the array elements for non-prime numbers: |
| 42 |
.PP |
| 43 |
.CS |
| 44 |
array set squares { |
| 45 |
1 1 6 36 |
| 46 |
2 4 7 49 |
| 47 |
3 9 8 64 |
| 48 |
4 16 9 81 |
| 49 |
5 25 10 100 |
| 50 |
} |
| 51 |
|
| 52 |
puts "The squares are:" |
| 53 |
parray squares |
| 54 |
|
| 55 |
\fBunset\fR squares(1) squares(4) squares(6) |
| 56 |
\fBunset\fR squares(8) squares(9) squares(10) |
| 57 |
|
| 58 |
puts "The prime squares are:" |
| 59 |
parray squares |
| 60 |
.CE |
| 61 |
.SH "SEE ALSO" |
| 62 |
set(n), trace(n), upvar(n) |
| 63 |
.SH KEYWORDS |
| 64 |
remove, variable |
| 65 |
'\" Local Variables: |
| 66 |
'\" mode: nroff |
| 67 |
'\" fill-column: 78 |
| 68 |
'\" End: |