Weird Code Errors

I keep getting the same errors, and don’t know what they mean.

#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Sensor, I2C_2, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Motor, port1, leftMotor1, tmotorVex393_HBridge, openLoop, driveLeft, encoderPort, I2C_2)
#pragma config(Motor, port2, leftMotor2, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port3, rightMotor1, tmotorVex393_MC29, openLoop, driveRight, encoderPort, I2C_1)
#pragma config(Motor, port4, rightMotor2, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port5, mobileGoal1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, mobileGoal2, tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma userControlDuration(105000)
#pragma autonomousDuration(15000)
task main()
{

task usercontrol()
{
	{
		motor(leftMotor1)= vexRT(Ch3)/2;
		motor(leftMotor2)= vexRT(Ch3)/2;
		motor(rightMotor1)= vexRT(Ch3)/2;
		motor(rightMotor2)= vexRT(Ch3)/2;

		if (vexRT[Btn6D]==1)
		{
			motor(mobileGoal1)=127;
			motor(mobileGoal2)=127;
		}
		else if(vexRT[Btn6U]==1)
		{
			motor(mobileGoal1)=-127;
			motor(mobileGoal2)=-127;
		}
		else
		{
			motor(mobileGoal1)=0;
			motor(mobileGoal2)=0;
		}
	}
	task autonomous()
	{
	thisisaplaceholder();
}
}

}

oh and the errors are

Error:Task ‘usercontrol’ is not defined at global scope level
Error:Tasks must be defined at main scope level
Warning:Unreferenced task ‘usercontrol’
Error:Task ‘autonomous’ is not defined at global scope level
Error:Tasks must be defined at main scope level
Warning:Unreferenced task ‘autonomous’

You can’t define a task within a task.

take out:

task usercontrol()
{
{

and the two of the closing curly braces at the end:

}
}

Also, you should occasionally press the “Fix Formatting” magic wand button.

@kypro

could I take out task main instead?

No, you need a “task main” in RobotC, analogous to the requirement for a “main” function in a standard C program.

In a competition template, “task main” is supplied by the vex_competition_includes.c, and you can’t supply it again.

Looking at your code again, was this supposed to be a competition template? If so, you don’t have enough stuff to make it work.

To get a new, clean competition template, select File->New->Competition Template.

Paste your code (piecewise) into that.

Here’s how that looks on the menu:

@kypyro your previous suggestion worked, however, autonomous still says that it is not defined at main and global scope level

Start with a clean competition template, and take the stuff that was in your old “main” and paste it into the new “task usercontrol” in the template.

Put any autonomous into “task autonomous” and you should be ready to code some more.

@kypyro
Thank you for the help!