ROBOTC.net forums
http://robotc.net/forums/

Set Bracket Has Been Rejected
http://robotc.net/forums/viewtopic.php?f=1&t=5176
Page 1 of 1

Author:  Alder [ Tue Nov 27, 2012 6:40 pm ]
Post subject:  Set Bracket Has Been Rejected

So, I made some basic code to make motors work when buttons are pressed. But for some reason it says there is some wrong with the last line. For the last setbracket, it gives the error: **Error**:Executable statements not valid in 'main' declaration block. If anyone knows why an '}' or any other thing isn't valid in the 'main' tell me what to fix and why it is caused please.
Here's the code:
#pragma config(Hubs, S1, HTMotor, HTServo, none, none)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone)
#pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone)
#include "JoystickDriver.c"

void intitializeRobot()
{
//Set servos to starting posistion//
return;
}

task main()
{
waitForStart();

//Autonomous code goes here.
}

// start off teleop code
while(true)
{
getJoystickSettings(joystick);
if(joy1Btn(7) == 1)
{
motor[motorD] = 100;
}
else if(joy1Btn(5) == 1)
{
motor[motorD] = -100;
}
else
{
motor[motorD] = 0;
}
// //
//SPACE(to make my life easier) //
// //
if(joy1Btn(6) == 1)
{
motor[motorE] = 100;
}
else if(joy1Btn(8) == 1)
{
motor[motorE] = -100;
}
else
{
motor[motorE] = 0;
// //
// SPACE (Before program de la claw) //
// //
if(joy1Btn(1) == 1)
{
motor[motorA]= 40;
}
else if(joy1Btn(2)== 1)
{
motor[motorA] = -40;
}
else
{
motor[motorA]= 0;
}
}
}

Author:  Alder [ Tue Nov 27, 2012 6:44 pm ]
Post subject:  Re: Set Bracket Has Been Rejected

Whoa. Never mind. I found the error in the code.
I put a left brace WAY too early in the code and it canceled out the rest of my code.
Sorry for the thread. :oops:

Author:  amcerbu [ Wed Nov 28, 2012 2:18 am ]
Post subject:  Re: Set Bracket Has Been Rejected

Just for future reference, I find it helps spot these sorts of errors to line up bracket levels, and use uniform indention (I do three spaces per "layer"). It also makes your code much more readable. Under the "Edit" menu in RobotC, there is actually a "Format Whole File" command that you might try out (it's really nifty). Something like this, for the indentation:
Code:
void function(int& integerArgument)
{
   if (abs(integerArgument) <= 100)
   {
      integerArgument = rand(0, 100);
      return;
   }
   else
   {
      if ((integerArgument % 7) == 0)
      {
         integerArgument *= 2;
         return;
      }
   }
   return;
}

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/