next up previous contents
Next: Case Statements Up: Statements Previous: Blocks and Exception Handling

Conditional Statements

 
  conditional_statement::= 'if' expression 'then' block [ alternative ] 'end' .
  alternative ::= 'else' block | 'elsif' expression 'then' block [ alternative ] .

Example: if a > b then res := 1 elsif a = b then res := 0 else res := -1 end tex2html_wrap_inline1707

A conditional statement is processed by first evaluating its expression, which must hold a result of type BOOL. Depending on this result the block (true) or the alternative (false), if any, are processed.

If the alternative starts with elsif then it is processed as if it were a conditional statement on its own.


Martin Trapp
Mon Feb 17 16:49:16 MET 1997