Next: , Previous: , Up: Statements   [Contents][Index]


7.2 IF Statement

The if statement selects one of two statements for execution, depending on a condition.

IF expr THEN statement1 [ ELSE statement2 ]

The condition expression expr is evaluated. Its value must be a scalar. If the value is non-zero, then statement statement1 is executed. If the condition evaluates to zero, and the optional else part was specified, then statement2 is executed. If the condition evaluates to zero but no else part was specified, then this statement does nothing and execution passes on directly to the next statement.