Does anyone know a simple solution for an issue I'm having regarding the number of levels you can have in an if statement??
I'm trying to receive a serial string, and do something based on the command received... And I want to have several commands.... I've seemed to run into a limit of levels that I can have...at around 14 or 15...
My code goes a little something like this...
if (device.readable()) {
device.scanf("%s", &string);
if (!strcmp(string, "led1")) {
led1 = !led1;
} else if (!strcmp(string, "led2")) {
led2 = !led2;
} else if (!strcmp(string, "led3")) {
led3 = !led3;
} else if (!strcmp(string, "led4")) {
led4 = !led4;
etc...etc....
I've tried figuring out how to use a switch statement, but get tripped up on the strcmp part... I'd love to have 30 or 40 commands and if anyone has any suggestions I'd be very happy to hear them!!
Thanks!!
Does anyone know a simple solution for an issue I'm having regarding the number of levels you can have in an if statement??
I'm trying to receive a serial string, and do something based on the command received... And I want to have several commands.... I've seemed to run into a limit of levels that I can have...at around 14 or 15...
My code goes a little something like this...
etc...etc....
I've tried figuring out how to use a switch statement, but get tripped up on the strcmp part... I'd love to have 30 or 40 commands and if anyone has any suggestions I'd be very happy to hear them!!
Thanks!!