[25] | 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 | '\" RCS: @(#) $Id: unset.n,v 1.13 2007/12/13 15:22:33 dgp Exp $ |
---|
| 10 | '\" |
---|
| 11 | .so man.macros |
---|
| 12 | .TH unset n 8.4 Tcl "Tcl Built-In Commands" |
---|
| 13 | .BS |
---|
| 14 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
| 15 | .SH NAME |
---|
| 16 | unset \- Delete variables |
---|
| 17 | .SH SYNOPSIS |
---|
| 18 | \fBunset \fR?\fI\-nocomplain\fR? ?\fI\-\-\fR? ?\fIname name name ...\fR? |
---|
| 19 | .BE |
---|
| 20 | .SH DESCRIPTION |
---|
| 21 | .PP |
---|
| 22 | This command removes one or more variables. |
---|
| 23 | Each \fIname\fR is a variable name, specified in any of the |
---|
| 24 | ways acceptable to the \fBset\fR command. |
---|
| 25 | If a \fIname\fR refers to an element of an array then that |
---|
| 26 | element is removed without affecting the rest of the array. |
---|
| 27 | If a \fIname\fR consists of an array name with no parenthesized |
---|
| 28 | index, then the entire array is deleted. |
---|
| 29 | The \fBunset\fR command returns an empty string as result. |
---|
| 30 | If \fI\-nocomplain\fR is specified as the first argument, any possible |
---|
| 31 | errors are suppressed. The option may not be abbreviated, in order to |
---|
| 32 | disambiguate it from possible variable names. The option \fI\-\-\fR |
---|
| 33 | indicates the end of the options, and should be used if you wish to |
---|
| 34 | remove a variable with the same name as any of the options. |
---|
| 35 | If an error occurs, any variables after the named one causing the error not |
---|
| 36 | deleted. An error can occur when the named variable does not exist, or the |
---|
| 37 | name refers to an array element but the variable is a scalar, or the name |
---|
| 38 | refers to a variable in a non-existent namespace. |
---|
| 39 | .SH EXAMPLE |
---|
| 40 | Create an array containing a mapping from some numbers to their |
---|
| 41 | squares and remove the array elements for non-prime numbers: |
---|
| 42 | .CS |
---|
| 43 | array set squares { |
---|
| 44 | 1 1 6 36 |
---|
| 45 | 2 4 7 49 |
---|
| 46 | 3 9 8 64 |
---|
| 47 | 4 16 9 81 |
---|
| 48 | 5 25 10 100 |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | puts "The squares are:" |
---|
| 52 | parray squares |
---|
| 53 | |
---|
| 54 | \fBunset\fR squares(1) squares(4) squares(6) |
---|
| 55 | \fBunset\fR squares(8) squares(9) squares(10) |
---|
| 56 | |
---|
| 57 | puts "The prime squares are:" |
---|
| 58 | parray squares |
---|
| 59 | .CE |
---|
| 60 | .SH "SEE ALSO" |
---|
| 61 | set(n), trace(n), upvar(n) |
---|
| 62 | .SH KEYWORDS |
---|
| 63 | remove, variable |
---|