RobotC compiler bug?

Hi
My daughter accidentally typed this

word modebutton_pressed = vexRT[btn7U];

and compiled. there were no errors, but when she went to test it, button 7 u did nothing… however when she moved the stick for axis 2 modebutton_pressed registered a value.

anyway I had a look at it and eventually spotted that it should have been.

word modebutton_pressed = vexRT[Btn7U];

and this fixed it, however up till then I was thinking that maybe the joystick was broken or something and was very confused for a while.

shouldn’t btn7U throw an error, or have I missed something. (btw this is in 3.54)

thanks
Steve

I just tested this and am able to confirm the different button mappings. The reason that this happens is because the uppercase Btn commands are the compiled mappings (Btn7U logically reads button 7 up) while the btn commands are the bit-masked values (in this case btn7U is referring to the horizontal axis of the right joystick, or axis 1). Because both are technically using the correct syntax in ROBOTC, it will not throw a compilation error at all.

Below is the ‘normal’ button mappings in ROBOTC:

Btn5D = 14,
Btn5U = Btn5D + 1,

Btn6D = Btn5D + 2,
Btn6U = Btn5D + 3,

Btn8D = Btn5D + 4,
Btn8L = Btn5D + 5,
Btn8U = Btn5D + 6,
Btn8R = Btn5D + 7,

Btn7D = Btn5D + 8,
Btn7L = Btn5D + 9,
Btn7U = Btn5D + 10,
Btn7R = Btn5D + 11,

And here are the bit-masked button groupings:

btn5D = 0x0001, // Button Group 5, Up
btn5U = 0x0002, // Button Group 5, Down
btn6D = 0x0004, // Button Group 6, Up
btn6U = 0x0008, // Button Group 6, Down

btn7D = 0x0100, // Button Group 7, Down
btn7L = 0x0200, // Button Group 7, Up
btn7U = 0x0400, // Button Group 7, Left
btn7R = 0x0800, // Button Group 7, Right

btn8D = 0x0010, // Button Group 8, Down
btn8L = 0x0020, // Button Group 8, Up
btn8U = 0x0040, // Button Group 8, Left
btn8R = 0x0080 // Button Group 8, Right

We plan on changing the names of the bit-masked button commands in the future (possibly to something like maskedbutton_Btn7U, for example), but in the meanwhile make sure you are using the correct capitalization when coding.

As always, thank you for the heads up on this and please do not hesitate to let us know if you run into any other issues, bugs, or glitches!

thanks, I did check the help but they weren’t mentioned there, however I’ve just noticed that if I right click and select go to definition I can see where they come from.

just wondering, can these be used anywhere in RobotC?
thanks
Steve

You should be able to use either method in a VEX program, however, the normal Btn commands are far easier to use and remember.