summaryrefslogtreecommitdiffstats
path: root/tcl8.6/doc/if.n
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2018-01-02 21:03:49 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2018-01-02 21:03:49 (GMT)
commit914501b5b992e7b6c7e0a4c958712a8ba9cab41c (patch)
treeedbc059b9557d5fdb79e5a5c47889bc54708da53 /tcl8.6/doc/if.n
parentf88c190a01bc7f57e79dfaf91a3c0c48c2031549 (diff)
downloadblt-914501b5b992e7b6c7e0a4c958712a8ba9cab41c.zip
blt-914501b5b992e7b6c7e0a4c958712a8ba9cab41c.tar.gz
blt-914501b5b992e7b6c7e0a4c958712a8ba9cab41c.tar.bz2
upgrade to tcl/tk 8.6.8
Diffstat (limited to 'tcl8.6/doc/if.n')
-rw-r--r--tcl8.6/doc/if.n88
1 files changed, 88 insertions, 0 deletions
diff --git a/tcl8.6/doc/if.n b/tcl8.6/doc/if.n
new file mode 100644
index 0000000..776f811
--- /dev/null
+++ b/tcl8.6/doc/if.n
@@ -0,0 +1,88 @@
+'\"
+'\" Copyright (c) 1993 The Regents of the University of California.
+'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+.TH if n "" Tcl "Tcl Built-In Commands"
+.so man.macros
+.BS
+'\" Note: do not modify the .SH NAME line immediately below!
+.SH NAME
+if \- Execute scripts conditionally
+.SH SYNOPSIS
+\fBif \fIexpr1 \fR?\fBthen\fR? \fIbody1 \fBelseif \fIexpr2 \fR?\fBthen\fR? \fIbody2\fR \fBelseif\fR ... ?\fBelse\fR? ?\fIbodyN\fR?
+.BE
+
+.SH DESCRIPTION
+.PP
+The \fIif\fR command evaluates \fIexpr1\fR as an expression (in the
+same way that \fBexpr\fR evaluates its argument). The value of the
+expression must be a boolean
+(a numeric value, where 0 is false and
+anything is true, or a string value such as \fBtrue\fR or \fByes\fR
+for true and \fBfalse\fR or \fBno\fR for false);
+if it is true then \fIbody1\fR is executed by passing it to the
+Tcl interpreter.
+Otherwise \fIexpr2\fR is evaluated as an expression and if it is true
+then \fBbody2\fR is executed, and so on.
+If none of the expressions evaluates to true then \fIbodyN\fR is
+executed.
+The \fBthen\fR and \fBelse\fR arguments are optional
+.QW "noise words"
+to make the command easier to read.
+There may be any number of \fBelseif\fR clauses, including zero.
+\fIBodyN\fR may also be omitted as long as \fBelse\fR is omitted too.
+The return value from the command is the result of the body script
+that was executed, or an empty string
+if none of the expressions was non-zero and there was no \fIbodyN\fR.
+.SH EXAMPLES
+.PP
+A simple conditional:
+.PP
+.CS
+\fBif\fR {$vbl == 1} { puts "vbl is one" }
+.CE
+.PP
+With an \fBelse\fR-clause:
+.PP
+.CS
+\fBif\fR {$vbl == 1} {
+ puts "vbl is one"
+} \fBelse\fR {
+ puts "vbl is not one"
+}
+.CE
+.PP
+With an \fBelseif\fR-clause too:
+.PP
+.CS
+\fBif\fR {$vbl == 1} {
+ puts "vbl is one"
+} \fBelseif\fR {$vbl == 2} {
+ puts "vbl is two"
+} \fBelse\fR {
+ puts "vbl is not one or two"
+}
+.CE
+.PP
+Remember, expressions can be multi-line, but in that case it can be a
+good idea to use the optional \fBthen\fR keyword for clarity:
+.PP
+.CS
+\fBif\fR {
+ $vbl == 1
+ || $vbl == 2
+ || $vbl == 3
+} \fBthen\fR {
+ puts "vbl is one, two or three"
+}
+.CE
+.SH "SEE ALSO"
+expr(n), for(n), foreach(n)
+.SH KEYWORDS
+boolean, conditional, else, false, if, true
+'\" Local Variables:
+'\" mode: nroff
+'\" End: