Select

<< Click to Display Table of Contents >>

Navigation:  Basic concepts > Statements >

Select

Syntax:

Select

  [<BoolExpression> do <Statements>]

End

The Select statement is a better option than the If statement when you need to test for many conditions. While similar in concept to the C "switch" statement or the Pascal "case" statement, the Select statement doesn’t require each case to be a constant value.

Example:

select 

   a > b do

      Print("A is greater than B")

 

   TimeNow() - previousTime > 1000 do

      Print("At least one second has passed")

      previousTime = TimeNow()

 

   true do

      Print("This executes if none of the other expressions were true")

end