|
| |||||||||||||
See also: do
if provides a mechanism for choosing from among a list of actions based on
given criteria.
An if block contains pairs of expressions. The first item of a pair is the "condition",
the second is the "action".
if executes conditions in order. The first condition that returns a value
other than false has its corresponding action executed and the value
of that action is returned from the call to if .
Subsequent clauses will be ignored.
If no conditions return a non-false result, then null is returned from the
call to if .
A condition that is literally true if reached, will always cause its action
to be executed.
The symbol else is a synonym for true .
<set x=52>
<if> x.<less 10/>
"got a 1 digit number"
x.<more 99/>
"got a big number"
else
"got a 2 digit number"
</if>
</set>![]() | "got a 2 digit number" |
<do /> block expression. (Remember that the call to <do /> returns the result
of the last expression in the call.)
<set x=150>
<if> x.<less 10 />
"got a 1 digit number"
x.<more 99 />
<do <set x=x.<plus 10 /> /> x />
else
"got a 2 digit number"
</if>
</set>![]() | 160 |
© Copyright 2007 Clear Methods, Inc.