diff options
author | dkf <dkf@noemail.net> | 2004-05-17 22:31:29 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2004-05-17 22:31:29 (GMT) |
commit | 5ebff9ad2637aed973f1f28c8f3056d393dc48e5 (patch) | |
tree | 39b6163ac3df3de286b2366cbd5dc1740bd231c1 /doc | |
parent | fcbbcb8810675708402e733c8e0b779ef8f00cd9 (diff) | |
download | tcl-5ebff9ad2637aed973f1f28c8f3056d393dc48e5.zip tcl-5ebff9ad2637aed973f1f28c8f3056d393dc48e5.tar.gz tcl-5ebff9ad2637aed973f1f28c8f3056d393dc48e5.tar.bz2 |
Added example
FossilOrigin-Name: bc2e40c928235be9e38e33802e2e17333606e5e2
Diffstat (limited to 'doc')
-rw-r--r-- | doc/uplevel.n | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/doc/uplevel.n b/doc/uplevel.n index 0d3bf6e..abbc4f2 100644 --- a/doc/uplevel.n +++ b/doc/uplevel.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: uplevel.n,v 1.3 2000/09/07 14:27:52 poenitz Exp $ +'\" RCS: @(#) $Id: uplevel.n,v 1.4 2004/05/17 22:31:31 dkf Exp $ '\" .so man.macros .TH uplevel n "" Tcl "Tcl Built-In Commands" @@ -72,6 +72,26 @@ describing a command that is either the outermost procedure call or the outermost \fBnamespace eval\fR command. Also, \fBuplevel #0\fR evaluates a script at top-level in the outermost namespace (the global namespace). +.SH EXAMPLE +As stated above, the \fBuplevel\fR command is useful for creating new +control constructs. This example shows how (without error handling) +it can be used to create a \fBdo\fR command that is the counterpart of +\fBwhile\fR except for always performing the test after running the +loop body: +.CS +proc do {body while condition} { + if {$while ne "while"} { + error "required word missing" + } + set conditionCmd [list expr $condition] + while {1} { + uplevel 1 $body + if {![uplevel 1 $conditionCmd]} { + break + } + } +} +.CE .SH "SEE ALSO" namespace(n), upvar(n) |