Go to Post *gasp* Robotics? bad for your health? I refuse to accept that as an answer. - Kiwi_queen [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-01-2004, 22:34
Unsung FIRST Hero
miketwalker miketwalker is offline
Robot Lifeguard
FRC #1902 (Exploding Bacon)
 
Join Date: Dec 2001
Rookie Year: 2002
Location: Orlando, FL
Posts: 878
miketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond repute
Send a message via AIM to miketwalker
Simple Syntax Error

I have a very simple code, but when I compile I keep getting syntax errors. Unfortunatly, the MPLAB does not tell you anything but that there is a syntax error. I've been trying to debug it, and it seems to be either the "void Autonomous_1()" line, or the IF loop. It seems like it should work, and multiple people have checked it and agreed. Does anybody see something that I'm not? It's so simple, I don't understand why it won't work. Thanks.

Code:
if (rc_dig_in01)
{
Autonomous_1();
}
else
{
Autonomous_2();
}

void Autonomous_1()
{
pwm01 = 254;
pwm02 = 254;
}

void Autonomous_2()
{
pwm01 = 127;
pwm02 = 127;
}
__________________
Chopsaw? Chopsaw.
  #2   Spotlight this post!  
Unread 05-01-2004, 23:43
Mike Soukup's Avatar
Mike Soukup Mike Soukup is offline
Software guy
FRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Schaumburg, IL
Posts: 797
Mike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond repute
Re: Simple Syntax Error

Can you give us the error message from the compiler? It would help greatly with the debugging. Even the line number will help. Do you have Autonomous_1 and Autonomous_2 defined in a header? If so, what do those lines look like? If you're having trouble getting something to compile that looks like it should, take out enough code to get it to at least compile. Then slowly add the code back in and you'll know where the problem is.
  #3   Spotlight this post!  
Unread 05-01-2004, 23:44
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Simple Syntax Error

Quote:
Originally Posted by miketwalker
Code:
if (rc_dig_in01)
{
Autonomous_1();
}
else
{
Autonomous_2();
}

void Autonomous_1()
{
pwm01 = 254;
pwm02 = 254;
}

void Autonomous_2()
{
pwm01 = 127;
pwm02 = 127;
}
Is that the code exactly as it appears in your file? If so, why isn't the IF statement inside a function?
  #4   Spotlight this post!  
Unread 05-01-2004, 23:45
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,586
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Simple Syntax Error

what's the code before the if statement? You don't have an ending bracket like you are closing a function.
  #5   Spotlight this post!  
Unread 05-01-2004, 23:51
Unsung FIRST Hero
miketwalker miketwalker is offline
Robot Lifeguard
FRC #1902 (Exploding Bacon)
 
Join Date: Dec 2001
Rookie Year: 2002
Location: Orlando, FL
Posts: 878
miketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond repute
Send a message via AIM to miketwalker
Re: Simple Syntax Error

I'm using this with the Edubot, I'm putting it in user_routines.c where it says to add your own code. The MPLAB compiler doesnt tell me anything other than "Error: syntax error" and it points at the space between where it closes the first IF loop, and where it says "void Autonomous_1()". I did try the method Mike said with taking some code out and adding it back. It seems to be the "void Autonomous_1()" and "void Autonomous_2()" lines. Do we have to have them defined in a header? If so, where and how... because I haven't done that.? Thanks!
__________________
Chopsaw? Chopsaw.
  #6   Spotlight this post!  
Unread 06-01-2004, 00:12
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Simple Syntax Error

well the most obvious problem is that you are trying do define function inside of functions. This is illegal. Put the declaration outside of any other functions. Things will work if you put the functions at the end of the code.
a better idea is this

----------------------------- edit --------------------------------
One good prectice is to put as much of any new code as possible in seperate files from the default IFI code and oly modify when need be. This makes code more portabe and keeps related things in one place. If you do this be sure to include your new files in whatever other files reference them. Also be sure to include whatever files your code references. Btw to create a new file and add it to a project, first create the file and save it with the appropriate file extention. this is not enough. if must then be added to the project file. the command to do this is on the project menu.

Also, while it is not mandatory in all compilers, it is a good idea to prototype your functions. This lets the compiler know what kind of arguments will be passed to them. In your case nothing is passed. add these lines(also outside of any other functions):
void Autonomous_1(void);
void Autonomous_1(void);
__________________
1139 Alumni

Last edited by Rickertsen2 : 06-01-2004 at 00:31.
  #7   Spotlight this post!  
Unread 06-01-2004, 00:17
Unsung FIRST Hero
miketwalker miketwalker is offline
Robot Lifeguard
FRC #1902 (Exploding Bacon)
 
Join Date: Dec 2001
Rookie Year: 2002
Location: Orlando, FL
Posts: 878
miketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond repute
Send a message via AIM to miketwalker
Re: Simple Syntax Error

Quote:
Originally Posted by Rickertsen2
well the most obvious problem is that you are trying do define function inside of functions. This is illegal. Put the declaration outside of any other functions
That was the problem. Thanks for the help!
__________________
Chopsaw? Chopsaw.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PBASIC Syntax Question Raven_Writer Programming 4 20-08-2003 08:07
PBASIC language syntax WizardOfAz Programming 14 30-04-2003 10:23
Basic Run Error BBFIRSTCHICK Programming 10 02-04-2003 22:43
EMERGENCY! EPROM FULL error?!? CHSguard72 Programming 2 05-03-2003 20:51
Basic Run Error Ulibrium Programming 12 21-02-2002 01:02


All times are GMT -5. The time now is 19:55.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi