combine elements from two sketches

I have just added some brackets and encoder0Pos-- and encoder0Pos++ and it worked.

void loop()
{

  n = digitalRead(encoder0PinA);// value of n = n is default LOW
  if ((encoder0PinALast == HIGH) && (n == LOW)) // int encoder0PinALast default LOW
  {
    if (digitalRead(encoder0PinB) == LOW)
    {
      
  if(lastButtonPushed = buttonPinLeft)
  encoder0Pos--;
    } 

    else if 
      
  (lastButtonPushed = buttonPinRight)
  encoder0Pos++;
    } 

    encoder0PinALast = n;
   

  navigateMenus();  //in some situations I want to use the button for other purpose (eg. to change some settings)
  readButtons();  //I splitted button reading and navigation in two procedures because 
}

ONE thing about this is that I have PINS assisigned to 43 and 45 for "buttonPinLeft" and "buttonPinRight". I can remove the wire connections for these and it still works but I have lost the use of TWO pins? If I remove 43 and 45 to become

const int encoderLeftRotation;
const int encoderRightRotation;

I get an uninitialized error.

Any Ideas on this...............anyone!

UKHeliBob as a reward for all your help Karma is duly awarded.