Return to Statement


Block IF Example 1

The simplest BLOCKIF construct consists of the IFTHEN and ENDIF statements. This construct conditionally executes one statement block.

   IFTHEN/a == b
MESSG/'ARRAY A IS EQUAL TO ARRAY B'
ENDIF

The statement first evaluates the logical expression a == b. If this value is true, then the program displays the message ARRAY A IS EQUAL TO ARRAY B. If the value is false, then the statement block is not executed and control transfers to the next executable statement after the ENDIF statement.

The following example contains a BLOCKIF construct using the ELSEIF statement.

   IFTHEN/a == b
MESSG/'ARRAY A IS EQUAL TO ARRAY B'
ELSEIF/a == c
MESSG/'ARRAY A IS EQUAL TO ARRAY C'
ENDIF

If the value of a is equal to b, the program displays the message ARRAY A IS EQUAL TO ARRAY B. If the value of a is equal to c, then the program displays the message ARRAY A IS EQUAL TO ARRAY C. But if neither expression is true, neither statement block is executed and control transfers to the next executable statement after the ENDIF statement.