Node: If, Next: , Previous: Foreach, Up: Statements



6.11.8 The if Statement

An if statement has the following form:

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

The elseif part may be repeated unrestrictedly (including zero times), the else part may be omitted.

First, 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 following statement is executed.

The if after the end may be omitted.