Conditional Commands - ifelse
General form:
ifelse [true/false condition][action if true][action if false]
make "variable1 23
make "variable2 23
ifelse :variable1 = :variable2 [print [It's TRUE]][print [It's FALSE]] produces
... It's TRUE
NOTE: There can be many 'actions' in the square brackets including procedures.
iftrue and iffalse
iftrue and iffalse are special applications of the "if" condition where a "test" command is applied first and then action is taken depending upon the result of the "test".
General use:
make "variable1 27
make "variable2 33
test :variable1 = :variable2
iftrue [print [The values are the same.]]
ifffalse [print [The values are different.]] produces ... The
values are different.
As previously discussed, the "action" can be a number of commands, or procedures.