Executable statements not valid in 'main'

#1

The Last Bracket is giving me this error message, and if i take it out it gives me more
Error:Executable statements not valid in ‘main’ declaration block
Can Someone please help

task usercontrol()
{
}
// User control code here, inside the loop

while (true)

{
motor[port3]=vexRT[Ch2];
motor[port2]=vexRT[Ch3];
motor[port5]=vexRT[Ch5];// set the motor, ‘LiftMotor’ to the left-hand rear buttons.
if(vexRT[Btn5U] == 1) // if Btn5U is pressed:
{motor[LiftMotor]=127;}
else
{motor[LiftMotor]=0;}
if(vexRT[Btn5D] == 1) // if Btn5D is pressed:
{motor[LiftMotor]=-127;}
else
{motor[LiftMotor]=0;}
motor[port6]=vexRT[Ch6];// set the motor, ‘FeedMotor’ to the right-hand rear buttons.
if(vexRT[Btn6U] == 1) // if Btn6U is pressed:
{motor[FeedMotor]=127;}
else
{motor[FeedMotor]=0;}
if(vexRT[Btn6D] == 1) // if Btn6D is pressed:
{motor[FeedMotor]=-127;}
else
{motor[FeedMotor]=0;
}
}

0 Likes

#2

task usercontrol()
{
}

This may be your problem right here. Any code that is run by a task or function needs to be ‘contained’ within its curly braces; in this case, the task usercontrol() is essentially empty. Instead, try this:

task usercontrol()
     {
        //All of your code goes here, in between the { and }
     }

This should solve the issue for you.

0 Likes

split this topic #3

2 posts were split to a new topic: Code trouble

0 Likes

closed #4
0 Likes