How to get my code to return to the start?

#pragma config(Sensor, dgtl1, Test, sensorTouch)
#pragma config(Motor, port2, Topleft, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port3, Topright, tmotorVex393, openLoop)
#pragma config(Motor, port4, Bottomleft, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port5, Bottomright, tmotorVex393, openLoop)
#pragma config(Motor, port6, Claw, tmotorVex393, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main()
{

wait1Msec(2000);
while(SensorValue(Test) == 1)
{
motor[Claw] = 127;
wait1Msec(2000);
}
while(SensorValue(Test) == 0)
{
motor[Claw] = -127;
wait1Msec(2000);
}
}

I am trying to get this to loop back to the top but instead it will only do the open and then close and then it will stop the code and i have to re run it but what i want it to do is.

task main()
{

wait1Msec(2000);
while(SensorValue(Test) == 1)
{
motor[Claw] = 127;
wait1Msec(2000);
}
while(SensorValue(Test) == 0)
{
motor[Claw] = -127;
wait1Msec(2000);
}
Back to start
}

How would I get it to return to the start? :confused:

If you want the code to run continually, you will need to put it inside some sort of loop. In the example below, and infinite while loop is used but there are other methods that you can use:

while(true)
{
  //All of the code you want to loop
}

This will continually loop through the code that you specify, over and over again, until the Cortex is turned off. You can learn more about loops in our Video Curriculum Trainer (http://www.education.rec.ri.cmu.edu/products/teaching_robotc_cortex/index.html), with the first introduction of loops found under the ‘Movement → Shaft Encoders → Forward for Distance’ section.

I have done what you said to do which ends me with this

#pragma config(Sensor, dgtl1, Test, sensorTouch)
#pragma config(Motor, port2, Topleft, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port3, Topright, tmotorVex393, openLoop)
#pragma config(Motor, port4, Bottomleft, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port5, Bottomright, tmotorVex393, openLoop)
#pragma config(Motor, port6, Claw, tmotorVex393, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main()
{
while(true)
{
wait1Msec(2000);
while(SensorValue(Test) == 1)
{
motor[Claw] = 127;

}
while(SensorValue(Test) == 0)
{
motor[Claw] = -127;

}
}
}

In which the code loops but the claw doesn’t open all the way like it barely opens at all almost as if its weak?