1 |
578 |
markom |
'\"
|
2 |
|
|
'\" Copyright (c) 1993-1997 Bell Labs Innovations for Lucent Technologies
|
3 |
|
|
'\" Copyright (c) 1997 Sun Microsystems, Inc.
|
4 |
|
|
'\"
|
5 |
|
|
'\" See the file "license.terms" for information on usage and redistribution
|
6 |
|
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
7 |
|
|
'\"
|
8 |
|
|
'\" RCS: @(#) $Id: variable.n,v 1.1.1.1 2002-01-16 10:25:25 markom Exp $
|
9 |
|
|
'\"
|
10 |
|
|
.so man.macros
|
11 |
|
|
.TH variable n 8.0 Tcl "Tcl Built-In Commands"
|
12 |
|
|
.BS
|
13 |
|
|
'\" Note: do not modify the .SH NAME line immediately below!
|
14 |
|
|
.SH NAME
|
15 |
|
|
variable \- create and initialize a namespace variable
|
16 |
|
|
.SH SYNOPSIS
|
17 |
|
|
\fBvariable \fR?\fIname value...\fR? \fIname \fR?\fIvalue\fR?
|
18 |
|
|
.BE
|
19 |
|
|
|
20 |
|
|
.SH DESCRIPTION
|
21 |
|
|
.PP
|
22 |
|
|
This command is normally used within a
|
23 |
|
|
\fBnamespace eval\fR command to create one or more variables
|
24 |
|
|
within a namespace.
|
25 |
|
|
Each variable \fIname\fR is initialized with \fIvalue\fR.
|
26 |
|
|
The \fIvalue\fR for the last variable is optional.
|
27 |
|
|
.PP
|
28 |
|
|
If a variable \fIname\fR does not exist, it is created.
|
29 |
|
|
In this case, if \fIvalue\fR is specified,
|
30 |
|
|
it is assigned to the newly created variable.
|
31 |
|
|
If no \fIvalue\fR is specified, the new variable is left undefined.
|
32 |
|
|
If the variable already exists,
|
33 |
|
|
it is set to \fIvalue\fR if \fIvalue\fR is specified
|
34 |
|
|
or left unchanged if no \fIvalue\fR is given.
|
35 |
|
|
Normally, \fIname\fR is unqualified
|
36 |
|
|
(does not include the names of any containing namespaces),
|
37 |
|
|
and the variable is created in the current namespace.
|
38 |
|
|
If \fIname\fR includes any namespace qualifiers,
|
39 |
|
|
the variable is created in the specified namespace.
|
40 |
|
|
.PP
|
41 |
|
|
If the \fBvariable\fR command is executed inside a Tcl procedure,
|
42 |
|
|
it creates local variables
|
43 |
|
|
linked to the corresponding namespace variables.
|
44 |
|
|
In this way the \fBvariable\fR command resembles the \fBglobal\fR command,
|
45 |
|
|
although the \fBglobal\fR command
|
46 |
|
|
only links to variables in the global namespace.
|
47 |
|
|
If any \fIvalue\fRs are given,
|
48 |
|
|
they are used to modify the values of the associated namespace variables.
|
49 |
|
|
If a namespace variable does not exist,
|
50 |
|
|
it is created and optionally initialized.
|
51 |
|
|
.PP
|
52 |
|
|
A \fIname\fR argument cannot reference an element within an array.
|
53 |
|
|
Instead, \fIname\fR should reference the entire array,
|
54 |
|
|
and the initialization \fIvalue\fR should be left off.
|
55 |
|
|
After the variable has been declared,
|
56 |
|
|
elements within the array can be set using ordinary
|
57 |
|
|
\fBset\fR or \fBarray\fR commands.
|
58 |
|
|
|
59 |
|
|
.SH "SEE ALSO"
|
60 |
|
|
global(n), namespace(n)
|
61 |
|
|
|
62 |
|
|
.SH KEYWORDS
|
63 |
|
|
global, namespace, procedure, variable
|