Order of Tasks/Functions
Page 1 of 1

Author:  Dave Crabbe [ Wed Oct 24, 2007 6:50 am ]
Post subject:  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.


Author:  vnguyen [ Wed Oct 24, 2007 9:44 am ]
Post subject: 

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:
void moveForward();

task main()
   motor[motorC] = 100;


void moveForward()
   motor[motorC] = 100;
   motor[motorB] = 100;

Thanks :)

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group