Help Programming Motor Encoders on easyC

I am having trouble programming motor encoders for my base. I use easyC but I don’t use the drag and drop. I’ve tried to program them by presetting the encoders to the number of rotations(in ticks) I need then setting the motors I want to 127 until the motor winds the motor encoder down to 0 at which point the motors are set to 0. I want to know why it doesn’t work. Also if there is a better way to do this then a sample code/explanation of the method would be much appreciated.

Forward for all of my base motors is +127
My right motors are 2(front) 1(back)
My left motors are 3(front) 10(back)
All motors have motor encoders and I have made sure my settings in the controller configurations are correct.
If motor 2 is set to +127 then the IMEs go down.
If motor 2 is set to -127 then the IMEs go up.
MainAuto (); is what would be called in the autonomous tab.

void RightTurn ()
{
InitIntegratedMotorEncoders();
SetMotor(2,-127);
SetMotor(1,-127);
SetMotor(3,127);
SetMotor(10,127);
PresetIntegratedMotorEncoder(2,-600);
if (GetIntegratedMotorEncoder(2) > 0) return;
};
void LeftTurn ()
{
InitIntegratedMotorEncoders();
SetMotor(2,127);
SetMotor(1,127);
SetMotor(3,-127);
SetMotor(10,-127);
PresetIntegratedMotorEncoder(2,600);
if (GetIntegratedMotorEncoder(2) < 0)
{
SetMotor(2,0);
SetMotor(1,0);
SetMotor(3,0);
SetMotor(10,0);
};
};
void MainAuto ()
{
RightTurn ();
LeftTurn ();
};

Thanks!

I think your problem is that the if statement is only checked once, and when it is checked evaluates to false, meaning the program just moves on to what is next. I don’t know if easyC has built in wait functions, but you can do it like this (I also avoided the method of setting encoders and running until they are zero, even though this works I don’t find it as ‘nice’ as counting up):

Reset Encoder to 0
Turn Motors On
While Encoder < 600:
    Empty Loop
Turn Motors Off

This way you are repeating the empty loop over and over, acting as a wait, until the encoder value passes 600. The same would go for the other turn, just adjust the values from positive to negative as necessary.