diff options
author | dkf <dkf@noemail.net> | 2004-05-27 22:13:45 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2004-05-27 22:13:45 (GMT) |
commit | b9547a4fc09354f87af7076fd39395f132d3a64e (patch) | |
tree | 3d3990dd1cd7242f465a9a9953f333f16e7510cd /doc | |
parent | c06aa532daf9926bfd033ca51d122c9b04e7d1f6 (diff) | |
download | tcl-b9547a4fc09354f87af7076fd39395f132d3a64e.zip tcl-b9547a4fc09354f87af7076fd39395f132d3a64e.tar.gz tcl-b9547a4fc09354f87af7076fd39395f132d3a64e.tar.bz2 |
Added examples
FossilOrigin-Name: db1b6b39aa580b6990c8c9c3dc8ac29c73b6c79f
Diffstat (limited to 'doc')
-rw-r--r-- | doc/variable.n | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/doc/variable.n b/doc/variable.n index 9ef4738..2f13edd 100644 --- a/doc/variable.n +++ b/doc/variable.n @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: variable.n,v 1.4 2000/11/21 15:56:21 dkf Exp $ +'\" RCS: @(#) $Id: variable.n,v 1.5 2004/05/27 22:13:45 dkf Exp $ '\" .so man.macros .TH variable n 8.0 Tcl "Tcl Built-In Commands" @@ -58,6 +58,39 @@ and the initialization \fIvalue\fR should be left off. After the variable has been declared, elements within the array can be set using ordinary \fBset\fR or \fBarray\fR commands. +.SH EXAMPLES +Create a variable in a namespace: +.CS +namespace eval foo { + variable bar 12345 +} +.CE +.PP +Create an array in a namespace: +.CS +namespace eval someNS { + variable someAry + array set someAry { + someName someValue + otherName otherValue + } +} +.CE +.PP +Access variables in namespaces from a procedure: +.CS +namespace eval foo { + proc spong {} { + # Variable in this namespace + variable bar + puts "bar is $bar" + + # Variable in another namespace + variable ::someNS::someAry + parray someAry + } +} +.CE .SH "SEE ALSO" global(n), namespace(n), upvar(n) |