The IF statement evaluates an expression and controls the flow of execution according to the result of that evaluation. The IF statement thus provides a conditional branch.
|
When expressions involve the use of the & and/or | operators, they are evaluated as described in Combinations of operations.
Each unit can be labeled and can have condition prefixes.
IF is a compound statement. The semicolon terminating the last unit also terminates the IF statement.
If any bit in the string expression has the value '1'B, unit1 is executed and unit2, if present, is ignored. If all bits are '0'B, or the string is null, unit1 is ignored and unit2, if present, is executed.
IF statements can be nested. That is, either unit can itself be an IF statement, or both can be. Since each ELSE is always associated with the innermost unmatched IF in the same block or do-group, an ELSE with a null statement might be required to specify a desired sequence of control. For example, if B and C are constants, the following example:
if A = B then
·
·
·
else if A = C then
·
·
·
else
·
·
·
is equivalent to and would be better coded as:
select( A ); when ( B )
·
·
·
when ( C )
·
·
·
·
·
·
end;