|
Alder
Rookie
Joined: Thu Oct 04, 2012 8:51 pm Posts: 22
|
 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; } } }
|
|
amcerbu
Novice
Joined: Sun Oct 21, 2012 10:01 pm Posts: 76
|
 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:
|