How to execute a line, once only within a function.

I am writing sensor values from an ADC to a memory LCD continuously. Because I dont want a flashing text, I write the value to the LCD and on the next cycle, I write the old value in white and then the new value in black. This gives a nice smooth change in values.

When the value of another ADC input goes low, I want to clear the screen and write something else only while this input is low.
This is simple enough except for the Clear Screen command. How do I prevent the ClearScreen from repeating while the input is low.

loop(){
  //Read Sensor on ADC0
  while (adc1 input HIGH){
     displaySensor()
      }
  clearScreen
  displayAlternate()
}

void displaySensor(){
      display sensor values
      }

// do this while adc1 is LOW
void displayAlternate(){
      display alternate text
     }

In the above, the clearScreen command is repeated every cycle so the display flashes. I just want to clear the screen once when adc1 goes low.

I want to clear the screen and write something else only while this input is low.

First, you need to decide what you want. Do you want to write WHILE the pin is LOW? Or, do you want to write when the pin BECOMES LOW? Your requirement, as stated, can not be implemented.

When adc0 is becomes LOW, I want to clear the screen ONCE and keep writing the Alternate Text until such time as adc0 goes high.

How about this approach.

loop(){
//Read Sensor on ADC0
while (adc1 input HIGH){
displaySensor()
}

adc1 is LOW

do
{
clearScreen // process once
}while( adc1 input HIGH)// false , done

adc1 is stil low or maybe not

while( adc1 input low)
{
displayAlternate()
}

}

OR you could just clear the screen when the state changes like this

bool adcWas;

loop(){
bool adcIS=adc input;
  
  if (adcIS != adcWAS)
    clearScreen
    
   if (adcIS==LOW)
       displayAlternate();
  
  if (adcIS HIGH)
     displaySensor()

}

void displaySensor(){
      display sensor values
      }

// do this while adc1 is LOW
void displayAlternate(){
      display alternate text
     }

Thanks
I used a combination of Boolean and then While inside the Alternate function.
much appreciated.