Structs are useful when doing more complex programming. For those who don't know what they are, structs are variables made of a collection of other variables. Again, this is not unique to
ROBOTC, but still useful in general, and not as widely known to beginning programmers. I'll demonstrate with an example:
Code:
typedef struct{
int maxPos;
int minPos;
int armSpeed;
int prevSensorValues[10];
} robotArm;
This is an example of a struct. If you have multiple arms on your robot, you can have a struct to hold the properties of each one.
A struct is implemented, and its components are accessed like this:
Code:
robotArm leftArm;
leftArm.maxPos = 2000;
leftArm.minPos = 150;
leftArm.armSpeed = 100;