Copyright 2008 Shoptalk Systems


The SELECT CASE statement makes it easy to execute different code paths depending on provided or computed values.  This is a cleaner shorthand for nested IF THEN/ELSE/END IF statements.


The SELECT CASE statement is supported in the following form.

for x = 1 to 10
  select case int(rnd(1)*4)
    case 0
      print "red"
    case 1
      print "green"
    case 2
      print "blue"
    case else
      print "other"
  end select
next x

The expression doesn't need to be numeric.  For example:

input "Type red, green or blue"; colorName$
select case colorName$
  case "red"
    print "The color is red"
  case "green"
    print "The color is green"
  case "blue"
    print "The color is blue"
  case else
    print "Invalid entry"
end select