View unanswered posts | View active topics It is currently Sun Oct 26, 2014 5:33 am






Reply to topic  [ 2 posts ] 
Order of Tasks/Functions 
Author Message
Rookie

Joined: Sat Jun 02, 2007 8:54 pm
Posts: 17
Post Order of Tasks/Functions
I am used to creating my main task first and then putting subroutines / functions after the main task. When I did this I got all kinds of errors.. I finally tried putting my subroutines / function before the task main and everything worked..

Is this a limitation of RobotC being interpretive rather than compiled?

(I'm going out on a limb here.. I think robotC is interpretive.. maybe I'm wrong)

It's not a huge thing to get used to, but I generally like to put my 'blocks' in order of importance as I write.

Dave


Wed Oct 24, 2007 6:50 am
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 439
Location: Pittsburgh, PA
Post 
Hi again :) Actually, that's a formality of the C language. If you want to place functions above task main, you must first "prototype" the functions above task main.

For example:
Code:
void moveForward();

task main()
{
   moveForward();
   motor[motorC] = 100;
   wait1Msec(3000);

}

void moveForward()
{
   motor[motorC] = 100;
   motor[motorB] = 100;
   wait1Msec(2000);
}


Thanks :)

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Use the ROBOTC Ticketing system

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Wed Oct 24, 2007 9:44 am
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:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.