News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

switch case

Started by gromit, May 05, 2012, 09:42:56 PM

Previous topic - Next topic

gromit

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 :) :) :)

TimoVJL

From help:
A range of values can be specified as an extension: case constant-expression ... constant-expression - see the /Zx option. [4.00]
May the source be with you

CommonTater

Alternatively.... if compatibility is an issue use an if() else if() cascade in place of your switch statement.


if ((x < subjump+20) && (x >= subjump))
  { do_whatever() }
else if (...

gromit

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


Stefan Pendl

Quote from: gromit on May 06, 2012, 08:55:33 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 ;)
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

Quote from: gromit on May 06, 2012, 08:55:33 AM
However i would be interested to know how to implement the zx option

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