How to send str variable that needs to be changed in library back to main prog?

I am working on a piece of hardware that has eighteen 7 segment LED modules on it.
I am using a library called SevSeg by Dean Reading to get me through driving the 18 LED modules.
I had to modify the library a bit because:
a) the existing circuit has two DM74LS138 BCD decoders to take 6 data lines and break it out to 18 LED module select lines. Since I must use them I modded the library to handle that.
b) to make matters worse the circuit also multiplexes buttons on the same common anode lines that the 7 segment LED modules use. I am handling multiplexing on two different fronts at once.
This was an early 80’s era piece of gear that did not have many IO lines to spare so they used every trick they could to save lines. The Arduino Due has plenty of lines but I have no desire to modify the UI electronics so it must operate as stock.

The fact that the buttons are being multiplexed with the LED modules common anode makes timing especially important. I am not using IRQ’s for this. But let’s say LED module 3 is being lit and the multiplexed button on that anode line is simultaneously pressed. I have to act on that while I am still in that iteration of the library or I may find myself with bad button information. At the moment I have it all working and when I press a button I Serial.print that button number just to confirm my button press.

Now instead of doing a Serial.print I want to do other useful work with a button press. For now I want to run a switch case statement and modify the string that is being displayed. The string is declared at the top of the main program and is passed to the library. Where I am lost is why I cannot modify the string within the library. I get ‘displayVar’ not declared in this scope but it should be public as it was declared before the main loop.

My program is growing large, spanning a few tabs but that is probably due to my inefficient brute force programming skills. This is probably my most complex Arduino project and while I have the electronics background I am certainly lacking in the programming department. I am proud of how far I got so far with no help but alas I think I may need to reach out for some guidance now. The variable I would like to effect is dispLeft[10] that is declared in the main program. Here are snippets of my code:

//This is main program

char dispLeft[10] = "123daniel";  // Nine characters plus null character

void loop()
updateledsLeft();

void updateledsLeft()     //This function used to update 7 segment LED arrays on left side.
{
  sevsegleft.setCharsLeft(dispLeft);
  sevsegleft.refreshDisplayLeft();

  
  return;
}
//This is the library

void SevSegLeft::refreshDisplayLeft() {

  if (!updateWithDelays) {

    // Exit if it's not time for the next display change
    if (micros() - prevUpdateTime < ledOnTime) return;
    prevUpdateTime = micros();


    // I USE RESISTORS ON SEGMENTS, UPDATE WITHOUT DELAYS

    // Turn all lights off for the previous digit
    for (byte segmentNum = 0 ; segmentNum < 8 ; segmentNum++)
    {
      digitalWrite(segmentPinsLeft[segmentNum], segmentOff); //Shut all 8 segment pins off
    }

    prevUpdateIdx++;
    if (prevUpdateIdx >= numDigits) prevUpdateIdx = 0;
    byte digitNum = prevUpdateIdx;
    
    for (byte bcd = 0; bcd < 4; bcd++)  //Counter used to read each column in the binary number contained within variable digitNum
    {
      byte state = bitRead(digitNum, bcd); // Read digitNum and use loop to extract binary equivalent. Counter BCD will increment and read binary position
      digitalWrite(digitPinsLeft[bcd], state);  //Output digitNum in BCD on designated pins
      
      buttonStateLeft = digitalRead(7); //Read input pin 7

      if ( (millis() - lastDebounceTime) > debounceDelay)
      {
        if (buttonStateLeft == LOW && digitNum < 8)
        {
          switch(digitNum)
          {
            case 0:
            dispLeft[10] = "button 00";
            case 1:
            dispLeft[10] = "button 01";
            case 2:
            dispLeft[10] = "button 02";
            case 4:
            dispLeft[10] = "button 03";
            default:
            dispLeft[10] = "whatever"; //etc etc
            break;
          }
          Serial.print("Button #");
          Serial.print(digitNum);
          Serial.println();
          delay (10);
          lastDebounceTime = millis(); //set the current time
        }
      }//close if(millis time buffer)
    }

Can someone provide a programming sample of how to handle this?

Thanks!

generatorlabs:
I get 'displayVar' not declared in this scope but it should be public as it was declared before the main loop.

I don't see any mention of displayVar in the code you posted. Did you maybe mean dispLeft?

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here using code tags.