Error in ROBOTC cortex default code

This is just an FYI.

I was working with the “ROBOTC VEX Cortex Default.c” sample file today (porting to you know what) and found it has a small bug.

Most (but not all, some are correct) statements using analog sensor values are using variables as an index rather than the analog port definitions. This means limit switches do not always work correctly. For example,

In this code


if((SensorValue[ana_6] < 200 && vexRT[Ch3Xmtr2] > 0) || (SensorValue[ana_5] < 200 && vexRT[Ch3Xmtr2] < 0))
    {
    motor[Mech3]        = 0;
    }
else
    {
    motor[Mech3]        = vexRT[Ch3Xmtr2];  // up = CW
    }

ana_6 should be ana6, ana_5 should be ana5.


if((SensorValue[ana6] < 200 && vexRT[Ch3Xmtr2] > 0) || (SensorValue[ana5] < 200 && vexRT[Ch3Xmtr2] < 0))
    {
    motor[Mech3]        = 0;
    }
else
    {
    motor[Mech3]        = vexRT[Ch3Xmtr2];  // up = CW
    }

Hello jpearman,

Thanks for the heads up on this; I’ve made the changes internally and we’ll make sure to update the Sample Programs for the next release. As always, please let us know if you run into any other bugs or glitches so we can address them directly.

Thanks again!