Select : EndSelect


Syntax
Select <expression1>
  Case <expression> [, <expression> [<numeric expression> To <numeric expression>]]
     ...
  [Case <expression>]
     ...
  [Default] 
     ...
EndSelect 
Description
Select provides the ability to determine a quick choice. The program will execute the <expression1> and retain its' value in memory. It will then compare this value to all of the Case <expression> values and if a given Case <expression> value is true, it will then execute the corresponding code and quit the Select structure. Case supports multi-values and value ranges through the use of the optional To keyword (numeric values only). If none of the Case values are true, then the Default code will be executed (if specified).

Note: Select will accept floats as <expression1> but will round them down to the nearest integer (comparisons will be done only with integer values).

Example: Simple example

  Value = 2
  
  Select Value
    Case 1
      Debug "Value = 1"
      
    Case 2 
      Debug "Value = 2"
      
    Case 20 
      Debug "Value = 20"
      
    Default
      Debug "I don't know"
  EndSelect

Example: Multicase and range example

  Value = 2
  
  Select Value
    Case 1, 2, 3
      Debug "Value is 1, 2 or 3"
      
    Case 10 To 20, 30, 40 To 50
      Debug "Value is between 10 and 20, equal to 30 or between 40 and 50"
      
    Default
      Debug "I don't know"
      
  EndSelect