unofficial: noob code error (need help fixing error)

In the official RobotC Technical Support Channel, @RoughRiderRobotics posted code with an error. It was:

The important bits are the actual Error messages. They are:

Which tells you what you did wrong. You left a “}” off at the end of the file.

To see this better, you should occasionally press the magic wand “Fix Formatting” button on the RobotC toolbar. This will indent the code, making it easier to see these kinds of mistakes.

If you want help quickly, post in an unofficial channel in the forum. It can take a day or so for the official channels to get attention.

Another helpful tip for a “noob” (your word, not mine) is that when posting code on the forum, enclose it in “code” tags. You can do this by pressing the “code” button in the “Start a conversation” toolbar. It’s the symbol that looks like </> .

Here’s your code, with indentation and that error fixed. I did nothing else.

task usercontrol()
{
	while(1 == 1)
	{
		//Claw Control
		if(vexRT[Btn6U] == 1)
		{
			motor[clawMotor] = 127;
		}
		else if(vexRT[Btn6D] == 1)
		{
			motor[clawMotor] = -127;
		}
		else
		{
			motor[clawMotor] = 0;
		}
		{
			//Arm Control
			if(vexRT[Btn5U] == 1)
			{
				motor[armMotor] = 127;
			}
			else if(vexRT[Btn5D] == 1)
			{
				motor[armMotor] = -127;
			}
			else
			{
				motor[armMotor] = 0;
			}
		}
	}
}

@kypyro

I think we had the same idea:)

https://vexforum.com/t/unofficial-noob-code-error-need-help-fixing-error/45241/1

So, if you look at the indented copy of your code, it looks like you had an extra open curly brace just before //Arm Control. So, instead of adding an extra closing curly brace at the end, you cold instead take out the extra open curly brace. Then your code would look like this:

task usercontrol()
{
	while(1 == 1)
	{
		//Claw Control
		if(vexRT[Btn6U] == 1)
		{
			motor[clawMotor] = 127;
		}
		else if(vexRT[Btn6D] == 1)
		{
			motor[clawMotor] = -127;
		}
		else
		{
			motor[clawMotor] = 0;
		}

		//Arm Control
		if(vexRT[Btn5U] == 1)
		{
			motor[armMotor] = 127;
		}
		else if(vexRT[Btn5D] == 1)
		{
			motor[armMotor] = -127;
		}
		else
		{
			motor[armMotor] = 0;
		}

	}
}

Wow. That’s amazing. Sorry for the clutter.

No worries.

Thanks, I will be sure to post in an unofficial channel next time.
I fixed the error, but I have another question. How would I start a code for the left and right drive motors?
I understand it’s a little different from the code I have for the arm and claw motors.
I plan on using and tank control driving style.

Here’s a very common and very simple way to do it.


		// Set left motor to value from left joystick
		// Set right motor to value from left joystick
		motor[leftDrive]   = vexRT[Ch3];
		motor[rightDrive]  = vexRT[Ch2];

Obviously, you have to set “leftDrive” and “rightDrive” to whatever is appropriate for your set up.

Okay, Thanks.