Encoder motor problem

Hello! we have put motor encoders on our robot and used them for our auton code but for some reason it has stopped our robot from working completely, for the time being we are using a time based auton, does anyone know what might be happening?
Here’s the code stopping our robot from working:
{
nMotorEncoder = 0;

int tickGoal = 58 * 10;

{
while nMotorEncoder < tickGoal)
motor[RFW] = 60;
motor[LFW] = 60;
motor[RBW] = 60;
motor[RFW] = 60;
}
{
{
if nMotorEncoder == tickGoal)

	motor[RFW] = 0;
	motor[LFW] = 0;
	motor[RBW] = 0;
	motor[LBW] = 0;
}

}
}

Thank you!

The line


while nMotorEncoder < tickGoal)

is a syntax error. Conditionals in C languages need parentheses () around the conditional. You have a trailing parenthesis, but did not include the leading one. The same problem on this line:


if nMotorEncoder == tickGoal)

After you fix those two, you will find that the logic flow of the program also doesn’t work. Both


if

and


while

will control the execution of the following statement, or block of statements denoted by a pair of {curly braces}. The statement immediately after your


while

is only


motor[RFW] = 60;

and the statement after your


if

is only


motor[RFW] = 0;

. None of your {curly braces} here actually do anything, except maybe the outermost set, whose context is not provided in your snippet.

I’m also not seeing how nMotorEncoder is supposed to change, so I think that your while loop will block forever and never terminate.

Thank you!