Help with some code...

This is my code for a project. I'm getting the error that I have not defined "manualmovement" in this scope. My code is below... (the error is in the sub routine)
#include <LiquidCrystal.h> //include the liquid crystal libary
#include <Servo.h> //include the servo libary
#include <Stepper.h> //include the stepper libary
#define in1 A2// connecting segment C to A2 //define the motor controller inputs
#define in2 A3// connecting segment A to A3 //define the motor controller inputs
#define in3 A4// connecting segment B to A4 //define the motor controller inputs
#define in4 A5// connecting segment C to A5

int stepDelayFull = 5; //different types of delays on command
int stepDelayHalf = 5; //another type of delay on command
int sectionDelay = 1000; //last type of on command delay

Servo Pan; //defining the servo pan
Servo Tilt; //defining the servo tilt

int pos = 180; //set the servos to 180 degrees

int dirA = A2; //stuff for the step motor
int dirB = A3; //stuff for the step motor
int pwmA = A4; //stuff for the step motor
int pwmB = A5; //stuff for step motor

Stepper stepper1(200, dirA, dirB); //setting up the direction commands for the stepper motor

int postilt = random (80, 180); //this controls the tilt position of the toy (with ranges)
int pospan = random (0, 180); //this controls the pan position of the toy (with ranges)
int rtone1 = random (100, 1000); //random tone 1
int rtone2 = random (100, 1000); //random tone 2

int valtilt; //varaible to read the value from the analog pin
int valpan; //varaible to read the value from the analog pin
int valpananalog; //for the analog amount var.
int valtiltanalog; //for the analog amount var.
int potpin = A0; //for the pot.
int potpin1 = A1; //for the pot.

int readbutton; //for the button
int readinput; //for the switch
int readinputtreat; //for the treat button

int switch_pan = 2; //for the manual or automatic toggle switch, assigning a pin to it

LiquidCrystal lcd(5, 3, 11, 10, 9, 8); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)

void setup() {
lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display }
Serial.begin(9600); //to see all input values
Serial.setTimeout(50); //delay between readouts
Pan.attach(6); //attaching the pan servo to pin 6
Tilt.attach(7); //attaching the tilt servo to pin 7
pinMode(A2, OUTPUT); //telling the arduino that these analog pins are outputs
pinMode(A3, OUTPUT); //telling the arduino that these analog pins are outputs
pinMode(A4, OUTPUT); //telling the arduino that these analog pins are outputs
pinMode(A5, OUTPUT); //telling the arduino that these analog pins are outputs
pinMode(pwmA, OUTPUT); //telling the arduino that this is a output
pinMode(pwmB, OUTPUT); //telling the arduino that this is a output

// Set PWM pins as always HIGH
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);

// Set stepper motor speed
stepper1.setSpeed(60);
}
void loop() {

int rdelay = random (500, 4000); //random delay between 500miliseconds and 4000
int rtone1 = random (100, 1000); //random tone 1
int rtone2 = random (100, 1000); //random tone 2

readinput = digitalRead ( 2 ); //read pin 2 (the switch)
//Serial.println(readinput); //print line
if(readinput ==1) //if the switch reads 1
manualmovement(); //go to manual control
if(readinput ==0) //if the switch reads 0
randommovement(); //do random control

readinputtreat = digitalRead ( 12 ); //read the pin 12 (the button)
//Serial.println(readinputtreat); //show me what the button is doing
if(readinputtreat ==1) //if the button is pressed
treats(); //do the treats command

}

void treats() { //all the stepper motor control code is below. Pulses to ove that is why there is so many high and low commands in there
for (int i = 1; i < 100; i ++){
forwardFull();
}
delay (sectionDelay);

for (int i = 1; i < 50; i ++){
reverseHalf();
}
delay (sectionDelay);

for (int i = 1; i < 200; i ++){
forwardHalf();
}
delay (sectionDelay);

for (int i = 1; i < 200; i ++){
reverseFull();
}
delay (5000);

}
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay (stepDelayFull);
//delay(20000); //delay for 20 seconds to allow kitten to get to the food
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);
delay(1000);
//delay(60000); //delay for one minute. This world be longer but this time is for presentation purposes
}

void randommovement(){
int postilt = random (0, 180); //this controls the tilt position of the toy (with ranges)
int pospan = random (50, 180); //this controls the pan position of the toy (with ranges)
Pan.write(pospan); //this is the code for the random tilt servo
delay(750); //750 millisecond delay
Tilt.write(postilt); //this is the code for the random pan servo
delay(750); //750 millisecond delay
lcd.setCursor(0,0); //set the cursor to 0,0 on the lcd display
lcd.write(" Random Mode"); //when in random mode to let the user know what mode they are in
lcd.setCursor(0,1); //set the cursor to go down a line of code
lcd.write(" Activated "); //print the next line of code
}
void manualmovement(){ //code for manual movement
lcd.clear(); //clear the lcd display so the old text isnt on there. Proably isnt nessacry but im doing that anyway
lcd.setCursor(0,0);
lcd.print("pan: ");
lcd.print(valtilt); //print the value from the pot. and print the tilt
lcd.setCursor(0,1); //change the cursour line to the bottom one
lcd.print("tilt: "); //what to say before the value
lcd.print(valpan); //print the value from the pot. and print the tilt
valpananalog = analogRead(potpin);
valpan = map(valpananalog, 0, 1023, 0, 180); //read the value from the pot
Pan.write(valpan); //go to the value of the pot
delay(100);

valtiltanalog = analogRead(potpin1);
valtilt = map(valtiltanalog, 0, 1023, 0, 180); //read the value from the pot
Tilt.write(valtilt); //go to the value of the pot
delay(100);

}

You have code outside of a function.

Where does the treats() function end ?

It would help to see the problem if you Auto formatted the code in the IDE

http://forum.arduino.cc/index.php/topic,148850.0.html

UKHeliBob:
You have code outside of a function.

Where does the treats() function end ?

It would help to see the problem if you Auto formatted the code in the IDE

UKHeliBob:
You have code outside of a function.

Where does the treats() function end ?

It would help to see the problem if you Auto formatted the code in the IDE

Here is the autoformatted code:
#include <LiquidCrystal.h> //include the liquid crystal libary
#include <Servo.h> //include the servo libary
#include <Stepper.h> //include the stepper libary
#define in1 A2// connecting segment C to A2 //define the motor controller inputs
#define in2 A3// connecting segment A to A3 //define the motor controller inputs
#define in3 A4// connecting segment B to A4 //define the motor controller inputs
#define in4 A5// connecting segment C to A5

int stepDelayFull = 5; //different types of delays on command
int stepDelayHalf = 5; //another type of delay on command
int sectionDelay = 1000; //last type of on command delay

Servo Pan; //defining the servo pan
Servo Tilt; //defining the servo tilt

int pos = 180; //set the servos to 180 degrees

int dirA = A2; //stuff for the step motor
int dirB = A3; //stuff for the step motor
int pwmA = A4; //stuff for the step motor
int pwmB = A5; //stuff for step motor

Stepper stepper1(200, dirA, dirB); //setting up the direction commands for the stepper motor

int postilt = random (80, 180); //this controls the tilt position of the toy (with ranges)
int pospan = random (0, 180); //this controls the pan position of the toy (with ranges)
int rtone1 = random (100, 1000); //random tone 1
int rtone2 = random (100, 1000); //random tone 2

int valtilt; //varaible to read the value from the analog pin
int valpan; //varaible to read the value from the analog pin
int valpananalog; //for the analog amount var.
int valtiltanalog; //for the analog amount var.
int potpin = A0; //for the pot.
int potpin1 = A1; //for the pot.

int readbutton; //for the button
int readinput; //for the switch
int readinputtreat; //for the treat button

int switch_pan = 2; //for the manual or automatic toggle switch, assigning a pin to it

LiquidCrystal lcd(5, 3, 11, 10, 9, 8); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)

void setup() {
lcd.begin(16, 2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display }
Serial.begin(9600); //to see all input values
Serial.setTimeout(50); //delay between readouts
Pan.attach(6); //attaching the pan servo to pin 6
Tilt.attach(7); //attaching the tilt servo to pin 7
pinMode(A2, OUTPUT); //telling the arduino that these analog pins are outputs
pinMode(A3, OUTPUT); //telling the arduino that these analog pins are outputs
pinMode(A4, OUTPUT); //telling the arduino that these analog pins are outputs
pinMode(A5, OUTPUT); //telling the arduino that these analog pins are outputs
pinMode(pwmA, OUTPUT); //telling the arduino that this is a output
pinMode(pwmB, OUTPUT); //telling the arduino that this is a output

// Set PWM pins as always HIGH
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);

// Set stepper motor speed
stepper1.setSpeed(60);
}
void loop() {

int rdelay = random (500, 4000); //random delay between 500miliseconds and 4000
int rtone1 = random (100, 1000); //random tone 1
int rtone2 = random (100, 1000); //random tone 2

readinput = digitalRead ( 2 ); //read pin 2 (the switch)
//Serial.println(readinput); //print line
if (readinput == 1) //if the switch reads 1
manualmovement(); //go to manual control
if (readinput == 0) //if the switch reads 0
randommovement(); //do random control

readinputtreat = digitalRead ( 12 ); //read the pin 12 (the button)
//Serial.println(readinputtreat); //show me what the button is doing
if (readinputtreat == 1) //if the button is pressed
treats(); //do the treats command

}

void treats() { //all the stepper motor control code is below. Pulses to ove that is why there is so many high and low commands in there
for (int i = 1; i < 100; i ++) {
forwardFull();
}
delay (sectionDelay);

for (int i = 1; i < 50; i ++) {
reverseHalf();
}
delay (sectionDelay);

for (int i = 1; i < 200; i ++) {
forwardHalf();
}
delay (sectionDelay);

for (int i = 1; i < 200; i ++) {
reverseFull();
}
delay (5000);

}
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay (stepDelayFull);
//delay(20000); //delay for 20 seconds to allow kitten to get to the food
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);

digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);
delay(1000);
//delay(60000); //delay for one minute. This world be longer but this time is for presentation purposes
}

void randommovement() {
int postilt = random (0, 180); //this controls the tilt position of the toy (with ranges)
int pospan = random (50, 180); //this controls the pan position of the toy (with ranges)
Pan.write(pospan); //this is the code for the random tilt servo
delay(750); //750 millisecond delay
Tilt.write(postilt); //this is the code for the random pan servo
delay(750); //750 millisecond delay
lcd.setCursor(0, 0); //set the cursor to 0,0 on the lcd display
lcd.write(" Random Mode"); //when in random mode to let the user know what mode they are in
lcd.setCursor(0, 1); //set the cursor to go down a line of code
lcd.write(" Activated "); //print the next line of code
}
void manualmovement() { //code for manual movement
lcd.clear(); //clear the lcd display so the old text isnt on there. Proably isnt nessacry but im doing that anyway
lcd.setCursor(0, 0);
lcd.print("pan: ");
lcd.print(valtilt); //print the value from the pot. and print the tilt
lcd.setCursor(0, 1); //change the cursour line to the bottom one
lcd.print("tilt: "); //what to say before the value
lcd.print(valpan); //print the value from the pot. and print the tilt
valpananalog = analogRead(potpin);
valpan = map(valpananalog, 0, 1023, 0, 180); //read the value from the pot
Pan.write(valpan); //go to the value of the pot
delay(100);

valtiltanalog = analogRead(potpin1);
valtilt = map(valtiltanalog, 0, 1023, 0, 180); //read the value from the pot
Tilt.write(valtilt); //go to the value of the pot
delay(100);

}

Here is the autoformatted code:

Complete with the same problem.

Where does the treats() function end ?

Why did you not use code tags when posting the code as suggested in read this before posting a programming question

Sorry about the code tag issue I won't do that again this is my first day and I should have read that post. As for the treat command are you referring to when I call it for the subcommand or when I define it with the void command?

As for the treat command are you referring to when I call it for the subcommand or when I define it with the void command?

I am asking where it ends. Where is its closing } ? Click on its opening { and the IDE will even put a box round the closing } for you to help you find it.

Find that and see what follows it. Does it belong in the function ?

Here is what I see

void treats()           //all the stepper motor control code is below. Pulses to ove that is why there is so many high and low commands in there
{
  for (int i = 1; i < 100; i ++)
  {
    forwardFull();
  }
  delay (sectionDelay);
  for (int i = 1; i < 50; i ++)
  {
    reverseHalf();
  }
  delay (sectionDelay);
  for (int i = 1; i < 200; i ++)
  {
    forwardHalf();
  }
  delay (sectionDelay);
  for (int i = 1; i < 200; i ++)
  {
    reverseFull();
  }
  delay (5000);
}
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay (stepDelayFull);
etc
etc

It does belong in the function

en0dog:
It does belong in the function

Then why is it outside of the function ?

  }
  delay (5000);
}  //the function ends here