View Single Post
  #5   Spotlight this post!  
Unread 23-11-2003, 22:08
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
limits for variable and program space are given at the innovations first webiste. As for putting ranges in the switch-case loop, to the extent of my knoledge, it cannot be done like in PBasic; you need to use some if statements. If it is just for one range and everything else is a single value, put it as a comparison in the default: tag, or as just the default tag if the situation permits. The other meathod is to create a char variable just for your switch-case loop and do some comparisons first, so it would look something like this:
Code:
char case_range
if(x<60)
{
   case_range=0;
}
else if(x<127)
{
   case_range=1;
}
else
   case_range=2;

switch(case_range)
{
   case 1:
      statements
   case 2:
      statements
   case 3:
      statements
}
And do that for however many cases you need. If you only need 2, you can even go with the whole ? : operator--case_range=(127<=x && 225>=x) ? 1 : 0.

On that note, does anybody know if you can nest the ?: operator? i.e. x=(condtion 1) ? 1 : (condition 2) ? 2 : (condition 3) ? 3 : ... (condition n) ? n : 0
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year