IF
Runs a block if a condition is true; or another block if it isn't.
Syntax
IF condition THEN BEGIN … END
IF condition THEN BEGIN … END ELSE BEGIN … END
IF condition THEN BEGIN … END ELSE IF condition THEN BEGIN … END ELSE BEGIN … END
| Argument | Meaning |
|---|---|
| condition | An expression that is TRUE or FALSE (or a number: 0 is false). |
THEN may be left out. ELSE may go at the start of the next line. As many ELSE IFs as are needed: the first
block whose condition is true is run, else the ELSE block, if there is one.
Examples
IF L > W THEN BEGIN
LINE P0, P2
END ELSE BEGIN
LINE P1, P3
END
A diagonal one way when the box is wider than it is tall, the other when it isn't: change L or W and it is
drawn again.
Notes
Compare with ==, != and ~= (nearly equal), not =: see Equal. To choose a value
rather than a block, use ? : or SWITCH.
See also: Blocks and control flow.