4.5. IF

Syntax:


        IF lexpr THEN
          statement_block
        [ ELSIF lexpr2 THEN
          statement_block ]
        [ ELSE
          statement_block ]
        END IF
      

This creates a test, or series of tests. The statement_block under the first lexpr that evaluates to 1 will be executed. Any number of ELSIF clauses are allowed. If no lexpr evaluates to true and the ELSE clause exists, the statement_block for the ELSE clause will be executed.

A special case of the IF statement is when any lexpr is a constant 0. In this case, the statement block is not parsed. This can be used for block comments.


        IF 0

        this is a dummy block that won't even be parsed!

        END IF
      

Example:


        IF x == 5 THEN
          y = 7
        ELSIF x == 6 THEN
          y = 12
        ELSE
          y = 0
        END IF