View Single Post
  #1  
Old 10-02-2011, 11:33 AM
jpearman's Avatar
jpearman jpearman is offline
Senior Member
VEX # 8888
 
Join Date: Apr 2011
Location: Los Angeles
Posts: 3,222
RobotC programming tips

We've had thread like this before, however, though I would start a new one for RobotC programmers to post their tips and tricks.

To start it off here are a couple that may not be known.

functions can have default values for their parameters, for example.

Code:
/ pointless demo code

void
forward( int speed = 100 )
{
    motor[ port2 ] = speed;   
}

task main()
{
    // Forward at default
    forward( );
   
    // Forward at speed 10
    forward( 10 );
   
    // Do nothing
    while( true ){
       wait10Msec(500);
    }
}
If the function "forward" is called with no parameters then the default of 100 is used.

If you have included your own library of functions, for example.

Code:
#include "motorLib.c"
you can suppress warnings about unused functions by including the line
Code:
#pragma systemFile            // eliminates warning for "unreferenced" functions
in the top of that file
Reply With Quote