compiling error

I am doing an incline (cable car) animation for my model railroad where a car is taken up and down the mountain continuously using a continuous servo and break beam IR sensors. I’ve got most of the bugs out but can’t figure this out. Error messages are at the bottom of the sketch. Appreciate any help for this newcomer - my first project. Thanks

/*  Servo modified to run continuously;  On startup, it looks for the
location of the car and starts it upward if at the bottom
and downward if at the top or in between. It then Stops when either top or bottom
IR sensor beam is broken; waits a period of time and starts in opposite 
direction   */


#include <Servo.h>
Servo motor;

void setup() {
  int IRTOP = 4;  // IR sensors hooked up to pins 4 and 5
  int IRBOT = 5;
  motor.attach(9);
  pinMode (IRTOP, INPUT_PULLUP);
  pinMode (IRBOT, INPUT_PULLUP);
  int topState = 0; // state of ir sensor  high if unbroken
  int botState = 0;
  //  find location of car and get it started
  topState = digitalRead (IRTOP);
  botState = digitalRead (IRBOT);
  if (topState == HIGH  && botState == LOW)  // car is at bottom
  {
    motor.write (95);  // start car to go up
  }
    else 
    {
      motor.write (85);  // car is in middle or top, start to go down
    }
}

void loop() {
  topState = digitalRead (IRTOP);
  botState = digitalRead (IRBOT);
  if (topState == LOW  || botState = LOW);  // stop the car
  {
    motor.write (90);
    delay (15000);
  }
  if (topState == LOW);  //car is ready to go down
  { 
    motor.write (85);
  }
   
    motor.write (95); // car is at bottom and ready to go up
}

Arduino: 1.7.3 (Windows 8.1), Board: "Arduino Uno"

Ver1_Servo_IR_sensors.ino: In function 'void loop()':


Ver1_Servo_IR_sensors.ino:34:3: error: 'topState' was not declared in this scope


Ver1_Servo_IR_sensors.ino:34:27: error: 'IRTOP' was not declared in this scope


Ver1_Servo_IR_sensors.ino:35:3: error: 'botState' was not declared in this scope


Ver1_Servo_IR_sensors.ino:35:27: error: 'IRBOT' was not declared in this scope


Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Several of your variables are defined in the setup function yet you try to use them in loop. They no longer exist when setup finishes.

Google "C++ scope" for further explanation.

Thanks now I’m getting another error

/*  Servo modified to run continuously;  On startup, it looks for the
location of the car and starts it upward if at the bottom
and downward if at the top or in between. It then Stops when either top or bottom
IR sensor beam is broken; waits a period of time and starts in opposite 
direction   */


#include <Servo.h>
Servo motor;

void setup() {
  int IRTOP = 4;  // IR sensors hooked up to pins 4 and 5
  int IRBOT = 5;
  motor.attach(9);
  pinMode (IRTOP, INPUT_PULLUP);
  pinMode (IRBOT, INPUT_PULLUP);
  int topState = 0; // state of ir sensor  high if unbroken
  int botState = 0;
  //  find location of car and get it started
  topState = digitalRead (IRTOP);
  botState = digitalRead (IRBOT);
  if (topState == HIGH  && botState == LOW)  // car is at bottom
  {
    motor.write (95);  // start car to go up
  }
    else 
    {
      motor.write (85);  // car is in middle or top, start to go down
    }
}

void loop() {
  int topState =0;
  int botState = 0;
  int IRTOP = 4;
  int IRBOT = 5;
  topState = digitalRead (IRTOP);
  botState = digitalRead (IRBOT);
  if (topState == LOW  || botState = LOW);  // stop the car
  {
    motor.write (90);
    delay (15000);
  }
  if (topState == LOW);  //car is ready to go down
  { 
    motor.write (85);
  }
   
    motor.write (95); // car is at bottom and ready to go up
}
/*
Arduino: 1.7.3 (Windows 8.1), Board: "Arduino Uno"

Ver1_Servo_IR_sensors.ino: In function 'void loop()':


Ver1_Servo_IR_sensors.ino:40:36: error: lvalue required as left operand of assignment


Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
*/
if (topState == LOW);

Oops.
You've still gôt the problem of the scope of IRTOP

botState = LOW)

nope.

Please work through some of the example code provided.

I figured out the last issue. it now compiles - to see if it works is next thanks for the help