View unanswered posts | View active topics It is currently Fri Jul 25, 2014 2:58 pm






Reply to topic  [ 3 posts ] 
Set Bracket Has Been Rejected 
Author Message
Rookie
User avatar

Joined: Thu Oct 04, 2012 8:51 pm
Posts: 22
Post 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;
}
}
}


Tue Nov 27, 2012 6:40 pm
Profile
Rookie
User avatar

Joined: Thu Oct 04, 2012 8:51 pm
Posts: 22
Post 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:


Tue Nov 27, 2012 6:44 pm
Profile
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post 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;
}


Wed Nov 28, 2012 2:18 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.