running switch case statement in switch case statement to read keypad twice

Geerings all.

i have a problem to read for the second time the keypad in a switch case senario.

i am reading a keypad to fill an 4 digit array and when i press # it wil start to reed the array bit for bit and does som actions based on the read action.
so it reads a 1 it is putting some outputs to high.
that part is working fine.

One of the steps is when it reads a bit with the value 4 it shoud start a second question witch should hav actions on the keypad again.
and based on that is should take further actions based on the autcome of that keypad entry.

but it wont start the second keypad read. ( it is a switch case inside a switch case )

whats wrong with the code ( or my way of thinking this was right )

Greetings adriaan

void lokadresisGoed()
  {
	\\some code to reset outputs

  for (int f = 0; f < 5; f++)
    {
        p = (locadres[f] - '0');
        switch (p) 
        {
          case 0: 
            {
			
			//some code to send zero to outputs	
            
			break;
            }
          case 1:
            {
			
			//some code to send one to outputs
            
			break;
            }
          case 2:
            {
			
			//some code to send two to outputs
			break;
            }
          case 3:
		  
		    
			// and so on for 3 to 9
		  
		    break;  
            }
          case 9:
            {

              //some code to send nine to outputs 

              break;  
            }
          default:
            {              
 
            //some code to set all outputs to off

            }
        }
    }
        
		//some code to ask if the direction is correct and run the direction test
		// to be answered with #=Yes / *=NO
		
		//This part is not working.
		//only when i press 2 times the # key it will go back to the main program
		
		char firstkey = customKeypad.getKey();
        firstkey = NO_KEY;
        if (firstkey != NO_KEY)
        {    
          switch(firstkey)
            {
             case '*': 
               {
                  // some code to run when * is pressed
				  // some code with an question on the lcd
				  // answered with #=yes / *=NO
				  
                  char subkey = customKeypad.getKey();
                  if (subkey !=NO_KEY)
                    {
                     switch(subkey)
                       {
                       case '*':
						{
          
						//some code to change direction and run the direction test

						break;	
						}
                       case '#':
					    {
                          
						  //some code run when direction is correct
						  
						  }
                       default:
                        {  
                        } 
                       }
                    }
				}
             case '#':
               {
                
				//Some code run when direction is correct
	
             default:
             {
             }
            }	 
        }           
    }      
          


void loop () {                                                                       
  char key = customKeypad.getKey();                                                  
  if (key != NO_KEY)                                                                 
  {
    switch(key)                                                                      
    {
      case '#':                                                                      
        lcd.clear();                                                                 
        lcd.setCursor(0,0);                                                          
        lcd.print("type adres ");                                               
        lcd.setCursor(0,1);                                                            
        lcd.print("Adres :  ");                                                      
        lcd.setCursor(16,1);                                                             
        lcd.print("A=Enter  C=clear");                                                       
        lcd.setCursor(8,1);                                                             
        z=0;                                                                         
        break;                                                                         
      case 'A':                                                                   
        delay(100);                                                                 
        lokadresisGoed();                                                          
        break;                                                                      
      case 'C':
        delay(100);
        memset(locadres,0,sizeof(locadres));                                         
        lcd.clear();                                                                 
        lcd.setCursor(0,0);                                                            
        lcd.print("Type adres ");                                               
        lcd.setCursor(0,1);                                                            
        lcd.print("Adres :  ");                                                      
        lcd.setCursor(16,1);                                                            
        lcd.print("A=Enter  C=Clear");                                                       
        lcd.setCursor(8,1);                                                           
        z=0;
        break;
      default:                                                                       
//        Serial.println(key);
        lcd.print(key);                                                             
        locadres[z]=key;                                                            
        z++;                                                                         
    }
  }
}

i am reading a keypad to fill an 4 digit array and when i press # it wil start to reed the array bit for bit and does som actions based on the read action.

Try that again. What is "it" that will start to read from what array?

Tools + Auto Format will fix that horrible indenting.

		char firstkey = customKeypad.getKey();
        firstkey = NO_KEY;
        if (firstkey != NO_KEY)

Now, really, do you expect that if statement to ever evaluate to true?

You seem to have some idea that the getKey() function waits for a key to be pressed. It does not. It simply determines, if one is being pressed, which one that is.

Hi first of all in my editor its perfectly lined up but when i paste the code here it is getting a horrible layout.

sorry the code was already changed, the line firstkey = NO_KEY; sould not have been there. ( was for testing)

Still it won't read the keypad for the second

void lokadresisGoed()  {
   \\some code to reset outputs
   for (int f = 0; f < 5; f++) {
        p = (locadres[f] - '0');
        switch (p) 
        {
          case 0: 
            {
           //some code to send zero to outputs	
            break;
            }
          case 1:

The array is "locadres", based on the content of the array bitwise the actions case 0 and case 1 are then put to work.
so if bit one is a 5, case 5 wil come in action.

after the readout of the 4 bits are done the program should move on to the next question where the kepad comes back in action to type a * or a # to get an YES or NO
the case * and case # after the question should result in some actions.

My technical english is not af good as yours ( i'm just a Dutch Guy )

Greeting Adriaan