Window opener opens window again and again due to Void loop

I changed the sketch according to the state change decection example:

// These constants won't change:
const int analogPin = A0;    // pin that the sensor is attached to
const int analogPin1 = A1;    // pin that the sensor is attached to
const int ledPin = 9;       // pin that the LED is attached to
const int ledPin1 = 8;       // pin that the LED is attached 
const int threshold = 350;   // an arbitrary threshold level that's in the range of the analog input
const int threshold1 = 145;   // an arbitrary threshold level that's in the range of the analog input

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
   pinMode(ledPin1, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // read the value of the potentiometer:
  int analogValue = analogRead(analogPin);
  int analogValue1 = analogRead(analogPin1);

  // if the analog value is high enough, turn on the LED:
  if (analogValue > threshold) {
    if (lastAnalogValue<threshold){
    digitalWrite(ledPin, HIGH);
    delay(4000);
    digitalWrite(ledPin, LOW);
    }
  } else {
    digitalWrite(ledPin, LOW);
  }
 if (analogValue < threshold) {
  if (lastAnalogValue>threshold){
    digitalWrite(ledPin1, HIGH);
    delay(4000);
    digitalWrite(ledPin1, LOW);
  }
     } else {
       digitalWrite(ledPin1, LOW);
        }
  // Temperatur in Spannung ausrechnen
  float voltage = (analogValue1/1024.0) * 5.0;
  //Temperatur in °C ausrechnen
  float temperature = (voltage - .5) * 100;
 
  // print the analog value:
 Serial.println("Dunkelheit ADC");
  Serial.println(analogValue);
  Serial.println("Temperatur ADC");
    Serial.println(analogValue1);
   Serial.println("Temperatur in °C");
    Serial.println(temperature);
      Serial.println("--------------------------------------------------------------  10s Delay");
  delay(10000);        // delay in between reads for stability
  lastAnalogValue=analogValue;
 }
 // Je heller, desto niedriger ist der Dunkelheit- Wert
 // Je wärmer,desto höher analogValue1

But I am getting a compiling error due to the folling line:
lastAnalogValue=analogValue;
The error says:
"'lastAnalogValue' was not declared in this scope".
So I checked the example sketch in order to find out what I did wrong.
The line missing in my sketch seems to be the following:
int lastButtonState = 0; // previous state of the button
However, as my sensor value is not digital, I am not sure what to replace the 0 with.