Multiple options for one CASE statement

Previous topic - Next topic

FutureCow

I would like to see CASE expanded to allow multiple, non-sequential options.

eg.
Code (glbasic) Select
select variable
  case 2,3,7
    print "2,3 or 7"
  ...



Moru

Oh, I always thought you could write this, but it doesn't work. No error message when compiling or running, it just ignores the 2 and 5
Code (glbasic) Select

LOCAL n = 5


SELECT n
CASE 1 OR 2 OR 5
DEBUG "1,2 or 5"
CASE 0
DEBUG "0"
DEFAULT
DEBUG "default"
ENDSELECT

FutureCow

I also tried this (which is the way some other languages do it) and it doesn't work either
Code (glbasic) Select
LOCAL n = 5


SELECT n
   CASE 1
   CASE 2
   CASE 5
      DEBUG "1,2 or 5"
   CASE 0
      DEBUG "0"
   DEFAULT
      DEBUG "default"
ENDSELECT

Moru

No, that way wouldn't be very intuitive in basic :-)