IFcondition
true.instructionlist
(IFcondition
true.instructionlist
false.instructionlist
)
Command or operation where:
If condition
evaluates to TRUE, then IF runs true.instructionlist
.
If condition
evalutes to FALSE, then IF does nothing.
If given a false.instructionlist
input, IF acts like IFELSE.
It is an error if condition
does not evaluate to either TRUE or FALSE.
For compatibility with earlier versions of Logo, if an IF instruction is not enclosed in parentheses and the first thing on the instruction line after the second input expression is a literal list (that is, a list in square brackets), then the IF is treated as if it were IFELSE and a warning message is given. If this aberrant IF appears in a procedure body, then the warning is given only the first time the procedure is invoked in each Logo session.
; single instruction list
IF 1=1 [PRINT [Yes it is true]]
Yes it is true
; two instruction lists
TO MAX :a :b
OUTPUT (IF :a > :b [:a] [:b])
END
SHOW MAX 1 2
2