Programming Trouble

Hi,
For my school we are working on a project that uses a Ultrasonic sensor. Our goal is to have the robot move until an object gets within 20 inches of the sensor. Being fairly near to ROBOTC programming, I have got the robot to move until the sensor detects an object. The problem now is that we want the robot to start moving again once the object moves out of the sensor range. What can I do?

-SScrub

Here is the code

#pragma config(Sensor, dgtl5, sonarSensor, sensorSONAR_inch)
#pragma config(Motor, port2, leftDrive, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, rightDrive, tmotorVex393_MC29, openLoop, driveRight)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main()
{

wait1Msec(2000); // Robot waits for 2000 milliseconds before executing program

while(SensorValue(sonarSensor) > 20 || SensorValue(sonarSensor) == -1) // Loop while robot’s Ultrasonic sensor is further than 20 inches away from an object
{ // || (or) it is ‘-1’. (-1 is the value returned when nothing is in it’s visable range)
motor[rightDrive] = 63; // Motor on port2 is run at half (63) power forward
motor[leftDrive] = 63; // Motor on port3 is run at half (63) power forward}
}
}

You need to put the code into a loop that will constantly monitor the sensor and decide of the motors should run forward or be stopped.

#pragma config(Sensor, dgtl5, sonarSensor, sensorSONAR_inch)
#pragma config(Motor, port2, leftDrive, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, rightDrive, tmotorVex393_MC29, openLoop, driveRight)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
  wait1Msec(2000);  // Robot waits for 2000 milliseconds before executing program

  // Do forever
  while(1) {
    if(SensorValue(sonarSensor) > 20 || SensorValue(sonarSensor) == -1) {
      motor[rightDrive] = 63; // Motor on port2 is run at half (63) power forward
      motor[leftDrive]  = 63; // Motor on port3 is run at half (63) power forward}
    }
    else {
      motor[rightDrive] = 0;  // Stop motor
      motor[leftDrive]  = 0;  // Stop motor
    }

    wait1Msec(20);
  }
}