View unanswered posts | View active topics It is currently Mon Nov 20, 2017 7:00 pm






Reply to topic  [ 2 posts ] 
Error in main, question on why the error occurs 
Author Message
Rookie

Joined: Fri Jan 30, 2015 9:58 pm
Posts: 3
Post Error in main, question on why the error occurs
Hi I have the following code to make a robot go straight, hit a wall, and then reverse to its original position:
Code:
task main()
{   
   int B = 0;
   int C = 0;
   int i;                                          //used to count dist back to sart position
   //nMotorEncoder[motorB] = 0;
   //nMotorEncoder[motorC] = 0;
   nMotorEncoder[motorB] = B;
   nMotorEncoder[motorC] = C;
   while(SensorValue(touch) == 0)    // While the Touch Sensor is inactive (hasn't been pressed):
   {
      motor[motorB] = 100;                        /* Run motors B and C forward */
      motor[motorC] = 100;                        /* with a power level of 100. */
      B++;                                                   // Increment variables to keep track of dist traveled
      C++;
   }
   // Otherwise (the touch sensor has been activated [pressed] )
   wait1Msec(1000);                        // Wait 1000 milliseconds (1 second) before moving to further code.
   for(i = 0; i <= B; i++)                 // Increment and drive motors until back to start position
   {
      motor[motorB] = -100;                    /* Run motors B and C backwards */
      motor[motorC] = -100;                    /* with a power level of -100.   */
   } 
}


I am getting the following errors when I try to compile it however, and completely do no know why?
Code:
File "N:\Documents\Ass1Robotc.c" compiled on Jan 30 2015 17:54:55
**Error**:Unexpected '/' during parsing
*Warning*:Undefined procedure 'main'. Global subroutine assumed.
*Warning*:Missing ';' has been automatically inserted by compiler
**Error**:Executable statements not valid in 'main' declaration block
**Error**:'task' keyword missing before 'main'


Could someone look at the error message and explain?


Fri Jan 30, 2015 10:03 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Error in main, question on why the error occurs
The code you posted looks good. It looks like we'll need to see all the rest of the code to help you track down the error. Can you post the entire code file, including the #pragmas?

_________________
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 Feb 03, 2015 10:14 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.