Why am I getting this error-not declared in this scope...

I have this loop:

void loop() {
  
  
  if (Serial.available() > 0) { //if serial incoming

     incomingByte = Serial.read(); //read it
    if (incomingByte==144){ // analyse the first byte (status) : 144 is note on ch1
    incomingByte = Serial.read(); //read the next byte

    if (incomingByte==60){ // analyse the second byte (note) : 60 is middle C

      incomingByte = Serial.read(); //read the next byte
      if(incomingByte>0){  //analyse the third byte : velocity >0
            int bitToSet = 1;
            registerWrite(bitToSet, HIGH);
      }else{ //analyse the third byte : velocity=0
            int bitToSet = 2;
            registerWrite(bitToSet, HIGH);
      }
    }

    }
  }
}

I am getting this error:

Serial_to_Midi.cpp: In function 'void loop()': Serial_to_Midi:39: error: 'incomingByte' was not declared in this scope

I'm confused if I need to declare incomingByte as an int or what. I'm confused because I don't see the variable declared anywhere in the example here: http://www.arduino.cc/en/Serial/Read

It is declared in the example: as a global variable before the setup() function.

You have to declare all variables somewhere.

Ah - I see it, thank you...