|
Page 1 of 1
|
[ 7 posts ] |
|
| Author |
Message |
|
vnguyen
Site Admin
Joined: Wed Jan 24, 2007 10:44 am Posts: 421 Location: Pittsburgh, PA
|
 Writing a "task main()"
Tip: When using task main(), you only have to type it once!
Be very careful with using the correct characters such as parenthesis "()", and curly braces "{}".
The proper format should be:
_________________Vu Nguyen Software Training Development Team | WebmasterNeed more support? Use the ROBOTC Ticketing systemRobotc.net| Robomatter Store | Robotics Academy
|
| Tue Mar 18, 2008 10:21 am |
|
 |
|
Dad and Adam
Novice
Joined: Thu Apr 17, 2008 6:04 am Posts: 70 Location: Plymouth, Indiana, USA
|
Hello,
Slowly I've been learning C and RobotC. I just noticed some of the sample RobotC programs have "task main ()" at the beginning and some don't have "task main () at all. I just tried my own simple program and it didn't seem to matter if I used "task main ()" or not.
What is the criteria for when "task main ()" must be used? How can it sometimes not be needed?
For example: The RobotC sample programs; "NXT Hello World", "Execution Speed Test", and "NXT Hello World Expanded" don't have the "task main()". They are 12, 496, and 33 lines of code respectively.
Thanks.
_________________ Dad (Dave) and Adam
|
| Thu Apr 17, 2008 6:12 am |
|
 |
|
Jetro
Rookie
Joined: Sat Oct 25, 2008 3:47 pm Posts: 38
|
 Re: Writing a "task main()"
I'm probably not the best person to try and answer your question seeing I'm a total noob at this, but I seem to remember that if a program has a "task main()" that task will be the first to be executed, no matter where it is located in the program. If it doesn't have a "task main()", the first task the compiler finds (reading from top to bottom) will be the first one to be executed.
Can anyone please confirm if I'm right?
|
| Sat Oct 25, 2008 6:57 pm |
|
 |
|
CC335
Expert
Joined: Sat Sep 20, 2008 12:16 pm Posts: 106 Location: Curently fighting aliens on P3X-828
|
 Re: Writing a "task main()"
A task main() is normally the first function, in this case a task, that the compiler reads. If there is no task main, it reads form top to bottom. I also program in C++, and with C++ you use int main(), with the parameters in the parentheses if used. RobotC thus looks like this: while C++ looks like this: Either way, the * main( parameters if used) is the first function to be read.
_________________ Sorry, your program could not be downloaded. Please reboot your computer. FTC Team #2959 Team Smash Bros CLICK HERE.(or click www) Agreed
|
| Sun Oct 26, 2008 5:35 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2905 Location: Rotterdam, The Netherlands
|
 Re: Writing a "task main()"
I think the examples without the task main() that are shipped with RobotC are really counter intuitive and terrible examples of how to program RobotC. It sets a bad precedent. I think it would be good to rewrite them with a task main().
Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Oct 26, 2008 6:42 pm |
|
 |
|
jagadeeshstel
Rookie
Joined: Sat Jul 30, 2011 10:03 am Posts: 7
|
 Operating system in NXT brick
which kind of operating system in NXT brick ? what is RobotC (its application or operating system to NXT brick)
|
| Tue Sep 06, 2011 2:27 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2905 Location: Rotterdam, The Netherlands
|
 Re: Writing a "task main()"
It's not really a full operating system but a small firmware. ROBOTC is both the programming language -and- the programming environment.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Tue Sep 06, 2011 2:34 pm |
|
|
|
Page 1 of 1
|
[ 7 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
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
|
|