Select-Case-Default-endSelect

Fast conditional branching and program execution with Constants comparison. If comparison is True, the code of this section is executed and then continued at the end of the Structure.

Syntax:

As of 2013.R1 addition range check is possible:

  select case a
  case 100 to 200,33,600 to 1000
    ...
  end select

Examples

  dim a,b as byte
  dim c as word
  dim d as long
 
' Sometimes it may make sense to define a Data Type, such as Byte()
'  select case Byte(a+b)
  select case (a+b) 'Expressions permitted
  case 1
    ' Program Code
  case "A","B"  ' also Strings permitted (1 character)
    ' Program Code
  case 2,3,0b10101010
    ' Program Code
  case 0x33
    ' Program Code
  default
    ' Program Code
  endselect
 
  'Word comparison
  select case c
  case 1
    ' Program Code
  case "AB","xy"  ' also Strings permitted, as of build 3815 (2 characters)
    ' Program Code
  default
    ' Program Code
  endselect
 
 'Long comparison
  select case c
  case 1
    ' Program Code
  case "ABCD","wxyz"  ' also Strings permitted, as of build 3815 (4 characters)
    ' Programmcode
  default
    ' Program Code
  endselect
  dim s as string
  select case s
  case "A"
    ' Program Code
  case "B","C","D"
    ' Program Code
  case "Super!"
    ' Program Code
  default
    ' Program Code
  endselect