Quote:
|
Originally Posted by Dave Scheck
...Chris posted while I was typing this....
Short answer is that #define and #if switches are processed before the compiler ever sees the code. Therefore you can't do what you are trying to do. You'd be better off storing the program number into a variable and deciding what to do based on that
Code:
enum
{
PROG_DO_NOTHING = 0,
PROG1,
PROG2
};
static int g_prog_num = PROG_DO_NOTHING;
....
if(rc_dig_in01==1)
{
g_prog_num = PROG1;
}
else if(rc_dig_in02==1)
{
g_prog_num = PROG2;
}
switch(g_prog_num)
{
case PROG1:
printf("Hello, world.");
break;
case PROG2:
printf("FIRST Robotics");
break;
default:
printf("DO NOTHING");
break;
}
|
Thank you very much for all the replies.
Dave, I am unfamiliar with the 'enum' command, what does it do? Assign values to the identities inside, ascending from the value assigned to the first identity?
Again, thank you very much,
