Select

The Select statement allows selection among multiple blocks of statements.

Syntax:

Select expression
 case
expression
  statements
  break
 case expression
  statements
  break
EndSelect

Parameters:

(s) expression an expression that must evaluate to an integer.

 

The Select statement allows selection among multiple blocks of statements, depending on the value of an expression. The expression must evaluate to an integer.

The Select statement causes the statements in the select body to be scanned by the parser as it attempts to find a case statement. When a case statement is found, the expression following the case statement is evaluated, and if the expression evaluates to the same value as the expression following the Select statement, execution of the following statements is initiated. The EndSelect statement terminates the Select structure.

If a matching case expression was found, and execution was initiated, the following statements will affect continued execution:

Note: Switch and Select may be used interchangeably. They are synonyms for the same statement.

EndSwitch, EndSelect, "End Switch", and "End Select" may be used interchangeably.

 

Example:


response=AskLine("Select", "Enter a number between one and three", 1, 0)
Select response
Case 1
   Message("Select", "Case 1 entered")
   Break
Case 2
   Message("Select", "Case 2 entered")
   Break
Case 3
   Message("Select", "Case 3 entered")
   Break
Case response ; default case
   Message("Select", "Default case entered")
   Break
End Select
See Also:

Switch, If, For, GoSub, While