diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-05-18 21:29:22 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-05-18 21:29:22 (GMT) |
commit | 46487a4cd235093ea1a14c1426132ac0f291428a (patch) | |
tree | 38ebef35c4701513506becd301798fa67d6d4073 /doc | |
parent | 8f44551e03712b6046cecdfc9e8ce0ba1b4a5225 (diff) | |
download | tcl-46487a4cd235093ea1a14c1426132ac0f291428a.zip tcl-46487a4cd235093ea1a14c1426132ac0f291428a.tar.gz tcl-46487a4cd235093ea1a14c1426132ac0f291428a.tar.bz2 |
Added example
Diffstat (limited to 'doc')
-rw-r--r-- | doc/upvar.n | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/doc/upvar.n b/doc/upvar.n index 84399c7..bb25fee 100644 --- a/doc/upvar.n +++ b/doc/upvar.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: upvar.n,v 1.6 2004/04/28 13:11:33 msofer Exp $ +'\" RCS: @(#) $Id: upvar.n,v 1.7 2004/05/18 21:29:22 dkf Exp $ '\" .so man.macros .TH upvar n "" Tcl "Tcl Built-In Commands" @@ -75,8 +75,7 @@ upvar variable. There is no way to unset an upvar variable except by exiting the procedure in which it is defined. However, it is possible to retarget an upvar variable by executing another \fBupvar\fR command. - -.SH Traces and upvar +.SH "TRACES AND UPVAR" .PP Upvar interacts with traces in a straightforward but possibly unexpected manner. If a variable trace is defined on \fIotherVar\fR, that @@ -104,6 +103,15 @@ is accessed (but traces on the particular element will still be invoked). In particular, if the array is \fBenv\fR, then changes made to \fImyVar\fR will not be passed to subprocesses correctly. .VE +.SH EXAMPLE +A \fBdecr\fR command that works like \fBincr\fR except it subtracts +the value from the variable instead of adding it: +.CS +proc decr {varName {decrement 1}} { + upvar 1 $varName var + incr var [expr {-$decrement}] +} +.CE .SH "SEE ALSO" global(n), namespace(n), uplevel(n), variable(n) |