Pelles C forum

C language => Windows questions => Topic started by: gromit on May 05, 2012, 09:42:56 PM

Title: switch case
Post by: gromit on May 05, 2012, 09:42:56 PM
Hi folks
Is there a better way
case   IDM_SUBJUMP:
case IDM_SUBJUMP+1:
case IDM_SUBJUMP+2:
case IDM_SUBJUMP+3:
case IDM_SUBJUMP+4:
case IDM_SUBJUMP+5:
case IDM_SUBJUMP+6:
case IDM_SUBJUMP+7:
case IDM_SUBJUMP+8:
case IDM_SUBJUMP+9:
case IDM_SUBJUMP+10:

I need another 10 yet
wondered if there was a way to do it with some sort of range etc
Big Thanks In Advance Gromit :) :) :)
Title: Re: switch case
Post by: TimoVJL on May 05, 2012, 09:57:45 PM
From help:
Code: [Select]
A range of values can be specified as an extension: case constant-expression ... constant-expression - see the /Zx option. [4.00]
Title: Re: switch case
Post by: CommonTater on May 05, 2012, 10:54:04 PM
Alternatively.... if compatibility is an issue use an if() else if() cascade in place of your switch statement.

Code: [Select]
if ((x < subjump+20) && (x >= subjump))
  { do_whatever() }
else if (...
Title: Re: switch case
Post by: gromit on May 06, 2012, 08:55:33 AM
Thanks for your answers folks
Although i have now revised my programming
That switch was a large popup sub menu that has become too large and i am now implementing it as a combobox

However i would be interested to know how to implement the zx option
is
it some sort of #define or #include ???
Be great to try to understand that
Big Thanks Gromit

Title: Re: switch case
Post by: Stefan Pendl on May 06, 2012, 09:54:08 AM
However i would be interested to know how to implement the zx option
You find this at Help => Contents => C Language Reference => Statements => switch statement ;)
Title: Re: switch case
Post by: CommonTater on May 06, 2012, 04:25:18 PM
However i would be interested to know how to implement the zx option

Project -> Project options -> Compiler -> Enable Pelles C Extensions  = checked.