View unanswered posts | View active topics It is currently Tue Nov 12, 2019 6:30 am






Reply to topic  [ 2 posts ] 
**ERROR**:Executable statements not valid in 'main' declarat 
Author Message
Rookie

Joined: Tue Dec 30, 2014 7:04 am
Posts: 1
Post **ERROR**:Executable statements not valid in 'main' declarat
The debug window keeps giving me this error message on my last line of code:
**ERROR**: Executable statements not valid in 'main' declaration block
i have no clue how to fix it :/ I've tried moving the code around, but then it just gives me more errors *sigh*


Attachments:
improved trial joystick.c [2.44 KiB]
Downloaded 396 times
Tue Dec 30, 2014 7:32 am
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: **ERROR**:Executable statements not valid in 'main' decl
Your brackets are a little out of whack. Here's your code reformatted so you can see it more clearly:
Code:
#pragma config(Hubs,  S1, HTServo,  none,     none,     none)
#pragma config(Hubs,  S2, HTMotor,  none,     none,     none)
#pragma config(Hubs,  S3, HTMotor,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Sensor, S3,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S2_C1_1,     rightmotor,    tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     leftmotor,     tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S3_C1_1,     rightarm,      tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S3_C1_2,     leftarm,       tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C1_1,    servo1,               tServoStandard)
#pragma config(Servo,  srvo_S1_C1_2,    servo2,               tServoContinuousRotation)
#pragma config(Servo,  srvo_S1_C1_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma debuggerWindows("joystickSimple");
#include "JoystickDriver.c"

task main()
{
   waitForStart();
   while(true)
   {
      getJoystickSettings(joystick);
      motor[rightmotor] = joystick.joy1_y1;
      motor[leftmotor] = joystick.joy1_y2;
   }

   if(joy1Btn(1) == 1)
   {
      motor[rightarm] = 100;
      motor[leftarm] = 100;
   }
   else
   {
      motor[rightarm] = 0;
      motor[leftarm] = 0;
   }

   if(joy1Btn(2) == 1)
   {
      motor[rightarm] = -100;
      motor[leftarm] = -100;
   }
   else
   {
      motor[rightarm] = 0;
      motor[leftarm] = 0;
   }
} // <- main() ends here

// This code is outside of main() - yikes!!!
while(true)
{
   servoChangeRate[servo1]= 10;
   servoChangeRate[servo2]= 10;

   short servoposition = 0;
   short moveservo = 0;

   servo[servo1] = servoposition;
   servo[servo2] = moveservo;

   if(joy1Btn(6) == 1)
   {
      servoposition = servoposition + 10;
   }

   if(joy1Btn(5) == 1)
   {
      servoposition = servoposition - 10;
   }

   if(joy1Btn(8) == 1)
   {
      moveservo = moveservo + 10;
   }
   if(joy1Btn(7) == 1)
   {
      moveservo = moveservo - 10;
   }
}    //error message here


All of the code you have here needs to be inside of main for it to compile properly. And another thing that won't generate an error, but will cause your program to run incorrectly is the fact that you have two different infinite loops and some code not in any loop. So, what your program will do is continually execute your driving code (inside the first while loop) and then never execute anything else. You need to enclose all of your driving code in one big infinite loop, like this:
Code:
task main()
{
     while (true)
     {
          // Put all driving code here
     }
}

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Tue Dec 30, 2014 1:40 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.