|
Page 1 of 1
|
[ 7 posts ] |
|
Author |
Message |
jcolonias
Rookie
Joined: Fri Sep 10, 2010 12:19 pm Posts: 7
|
 Help on Functions
Hi everybody
I am trying to run a ROBOTC program with functions and I get an error
**Error**:Functions must be defined at main scope level
Do you have an example of its meaning?
Thanks very much for the help!
John
|
Thu Nov 29, 2012 11:44 am |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Help on Functions
It sounds like you have mismatched braces. Make sure your code is indented properly. This will help you to spot mismatched braces. I don't have RobotC in front of me but there is an automatic "format whole file" item in the Edit menu if I remember correctly.
|
Thu Nov 29, 2012 2:06 pm |
|
 |
jcolonias
Rookie
Joined: Fri Sep 10, 2010 12:19 pm Posts: 7
|
 Re: Help on Functions
Thanks MHTS
I will try your suggestions.
John
|
Thu Nov 29, 2012 3:08 pm |
|
 |
amcerbu
Novice
Joined: Sun Oct 21, 2012 10:01 pm Posts: 76
|
 Re: Help on Functions
It often helps to use the "Format Whole File" button (under the Edit menu, in the Code Formatting section).
|
Thu Nov 29, 2012 3:14 pm |
|
 |
jcolonias
Rookie
Joined: Fri Sep 10, 2010 12:19 pm Posts: 7
|
 Re: Help on Functions
Hi, everybody
Thanks for your help, but I think I must be doing something that I cannot detect.
I am attaching the code. I have some errors that are not related to the function issues which I will correct once this problem is resolved.
What I am trying to do is write one function to be used for all robot movement, that is, go straight, turn, reverse, etc., by using "sub functions" within the main "move" function. I must be doing something that is totally wrong in declaring these "sub-functions".
Again, thanks for taking the time to look at this problem of mine.
John
|
Fri Nov 30, 2012 1:23 pm |
|
 |
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: Help on Functions
You're not calling functions correctly. Here is a simpler example of how to call functions: Do not call functions by defining them, e.g. void move(int movetime); p.s. Next time, please post your code in the [ code] [/code] tags provided.
_________________ sudo rm -rf /
|
Fri Nov 30, 2012 1:38 pm |
|
 |
jcolonias
Rookie
Joined: Fri Sep 10, 2010 12:19 pm Posts: 7
|
 Re: Help on Functions
Thanks magicode
PROBLEM SOLVED!!!!! I am a newbee!!!
John
|
Fri Nov 30, 2012 3:03 pm |
|
|
|
Page 1 of 1
|
[ 7 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
|
|