Nesting SWITCH . . . CASE

I'm trying to use nested SWITCH . . . CASE statements, i.e., one CASE inside another. What I find happening is that the 1st layer CASE sees the BREAK for the 2nd layer CASE and immediately exits. Can you nested these? What I ended up doing is changing the 2nd layer to an IF . . . WHILE statement and that works correctly.
Thanks, John

This sounds like a missing break; so that a fallthrough occurs.

If your case code gets to be complex, use function calls, but you should be able to make it work without them. It would help if you posted your code using code tags.

yes you can, just ensure you respect the various statements

switch(state) {

  case STATE1:
    someStuff();
    switch(command) {
      case CMD1: ••• break;
      case CMD2: ••• break;
      case CMD3: ••• break;
    } // end switch commmand
    someOtherStuff();
   break; // end of STATE1

  case STATE2:
    switch(command) {
       case CMD1: ••• break;
       case CMD2: ••• break;
       case CMD3: ••• break;
     } // end switch commmand
     break; // end of STATE2

} // end switch state 

remember as well that you can't define a variable within a case without creating a compound statement first, ie you can't do

switch(state) {
  case STATE1:
    int x = 22; // <=== Don't Create a variable directly in the case
    •••
    break;

you need to do

switch(state) {
  case STATE1:
    { // <=== start a compound statement
      int x = 22; // <=== OK, you are within the compound statement
      •••
    }// <=== end the compound statement
    break;