GLBasic forum

Feature request => IDE/Syntax => Topic started by: FutureCow on 2009-Oct-16

Title: Multiple options for one CASE statement
Post by: FutureCow on 2009-Oct-16
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"
  ...


Title: Re: Multiple options for one CASE statement
Post by: Moru on 2009-Oct-16
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
Title: Re: Multiple options for one CASE statement
Post by: FutureCow on 2009-Oct-16
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
Title: Re: Multiple options for one CASE statement
Post by: Moru on 2009-Oct-16
No, that way wouldn't be very intuitive in basic :-)