NO

Author Topic: switch case  (Read 4968 times)

gromit

  • Guest
switch case
« 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 :) :) :)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: switch case
« Reply #1 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]
May the source be with you

CommonTater

  • Guest
Re: switch case
« Reply #2 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 (...

gromit

  • Guest
Re: switch case
« Reply #3 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


Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: switch case
« Reply #4 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 ;)
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

  • Guest
Re: switch case
« Reply #5 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.