IF Statement

The IF statement is used to decide between sections of code to run. It takes a boolean expression as its argument. If the expression evaluates to TRUE then the first block of statements is executed and execution resumes after the END at the end of the whole block. If the expression is FALSE, then any ELSIF clauses are evaluated, until one of their arguments evaluates to TRUE and their block of code is executed. Execution then resumes after the END. If none of the ELSIF clauses evaluate to TRUE (or there are none), then if there is an ELSE clause, its statements are executed.

  IF expression THEN
    statements;
  { ELSIF expression THEN
    statements; }
  ...
  { ELSE
    statements; }
  END;

Example

  IF a < b THEN
    PRINT("a is less than b\n");
  ELSIF a > b THEN
    PRINT("a is greater than b\n");
  ELSE
    PRINT("a equals b\n");
  END;