Trying to find what is wrong with this code - if - then loop

Hi, I am trying to figure out why this robot code won’t execute – it seems to “skip” the first set of commands.

I am attempting to have a robot (EDR Vex Cortex) that sees an obstacle a certain distance away, and then stops, turns, and goes forward. But for now I just wanted something that responds to the sensor.

In any case this is what I have, using Vex 2.0 Cortex Natural Language.

I tried putting a repeat(forever) at the start, and it went to the first line and repeated – but didn’t execute any other code.

#pragma config(Sensor, dgtl4,  echo2,          sensorSONAR_cm)
#pragma config(Motor,  port1,           rightMotor,    tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port10,          leftMotor,     tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{

	setMotor(port1, -60);
	setMotor(port10, 60);//turn to left 
wait(1);
		stopMotor(port1);
	stopMotor(port10);
setMotor(port1, 60);
	setMotor(port10, 60);
	if(SensorValue[echo2] <=25)
	{motor[port1] = 0;
		motor[port10] = 0;}
	else
	{motor[port1]=60;
		motor[port10] = 60;}
	resetSensor(echo2);
}

Anyhow, help might be appreciated – maybe resetting the sensor was the problem? But the Robot C wizard tells me it doesn’t even get there.

Thanks

You need to put a whole loop surrounding actions that need to be repeated

while(sensorvalue[echo2] >25) {
setMotor(port1,60);
setMotor(port10,60);
}