next up previous contents
Next: The parallel Statement Up: Statements Previous: The foreach Statement   Contents

The if Statement

$$ If-Statement ::= "if" Condition "then" {Statement}
$$                  {"elseif" Condition "then" {Statement}}
$$                  "else" {Statement} "end" ["if"] ";" .

An if statement has the following form:

if condition1 then statements1
elseif condition2 then statements2
else statements3
end if ;

The second line may be repeated unrestrictedly (including zero times), the third line may be omitted.

Firstly, condition1 is evaluated. If it is satisfied, the statement sequence statements1 is executed.

If the first condition is not satisfied, condition2 is evaluated; if the result is true, statements2 is executed. This procedure is repeated for every elseif part until a condition is satisfied.

If the if condition and elseif conditions fail, the statement sequence statements3 is executed (if it exists).

After the if statement has been processed the next statement is executed.

The if after the end may be omitted.


next up previous contents
Next: The parallel Statement Up: Statements Previous: The foreach Statement   Contents
Bjoern Beutel