summaryrefslogtreecommitdiffstats
path: root/doc/variable.n
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-27 14:43:09 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-27 14:43:09 (GMT)
commit4955bdc67b8a5c3d9d12cf70cfe0b73c8a4f4ca8 (patch)
tree7a733c8f49dc66ae55cca35e7652f5bb0b1c51c6 /doc/variable.n
parent45beb64f7dcb09a6ce83532702bca760f72e6f4d (diff)
downloadtcl-4955bdc67b8a5c3d9d12cf70cfe0b73c8a4f4ca8.zip
tcl-4955bdc67b8a5c3d9d12cf70cfe0b73c8a4f4ca8.tar.gz
tcl-4955bdc67b8a5c3d9d12cf70cfe0b73c8a4f4ca8.tar.bz2
Finished user-level documentation backport
Diffstat (limited to 'doc/variable.n')
-rw-r--r--doc/variable.n35
1 files changed, 34 insertions, 1 deletions
diff --git a/doc/variable.n b/doc/variable.n
index 9ef4738..908e5ae 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.4.18.1 2004/10/27 14:43:15 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 {
+ \fBvariable\fR bar 12345
+}
+.CE
+.PP
+Create an array in a namespace:
+.CS
+namespace eval someNS {
+ \fBvariable\fR 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
+ \fBvariable\fR bar
+ puts "bar is $bar"
+
+ # Variable in another namespace
+ \fBvariable\fR ::someNS::someAry
+ parray someAry
+ }
+}
+.CE
.SH "SEE ALSO"
global(n), namespace(n), upvar(n)