Select Case expr
   Case value, value...
     commands
   Case Is <= value
     commands
   Case Else
     commands
 EndSelect

Multi-part decision. The expression expr is evaluated and compared to each of the Case blocks. The first matching block's commands are executed.

There can be any number of Case branches, each of which lists a number of values to match. For example,

 Case 1, 3, 5

matches numbers one, three or five. Using the Is keyword, you can also match on relations, as in

 Case Is >= 9

which matches all numbers greater or equal than nine. Each Case can contain any number of selectors separated by comma. Although these examples all use integer numbers, you can also select on real numbers or strings.

Cases are evaluated from top to bottom, the first matching one is taken. If no case matches, the Case Else, if present, is run.

Values in Case expressions should be constants, although this is not currently enforced.

Example:

 Select Case i
   Case 1
     Print "one"
   Case 2,3,4
     Print "two to four"
   Case Is < 10
     Print "below ten, but not one to four"
   Case Else
     Print "anything else"
 EndSelect

Since: PCC 1.1.13, PCC2 1.99.9

See also: If, Elementary Commands

This is a testing version.
It may be incomplete, and have more bugs (or features) than the public live version at planetscentral.com.