Vex button control not working?

So basically I started coding my robot, (C++, VCS) and then downloaded it onto my robot. The tank control worked fine, but the buttons ( L1 and R1) when pressed, wouldn’t do anything. I was wondering why. Below is a picture of my code. Thanks for any help!

Vex Code Snip 1.PNG

Where are all the vex:: parts? Have you locally redefined all those things that had been defined elsewhere? Most likely you haven’t, and the program doesn’t know where to find things like velocityUnits::pct. Try vex::velocityUnits::pct, for example. You have a whole bunch of those to fix.

It’s all in robot-config.h

So you’re saying if we include robot-config.h, then we don’t have to worry about the vex namespace?

If you are using Vex C++ or blocks. With C++ Pro you are on your own. For example, I dragged out a controller and one motor in robot config, this is the header that is generated.

using namespace vex;
vex::brain Brain;
vex::motor Motor1 (vex::PORT1, vex::gearSetting::ratio18_1,false);
vex::controller Controller1;

In Vex C++ and blocks you have no access to that file, it’s auto generated.

Ah, I see now. Not being able to see into robot-config.h in Vex C++ hides “using namespace vex;”. And I would guess with the restrictions in place in Vex C++, that’s far less likely to be a problem than “using namespace” might otherwise be.

So, since “using namespace vex;” is included, ignore my first post. Those parts aren’t a problem. I’m not seeing what’s wrong with the code, though. @7517j , have you tried it with just the code you sent? Was the tank control part removed to post that part? There could be something between the two, like the while loop ending after tank control and before the button presses. Have you double-checked the port for the motor to make sure it matches where the code things it is?

That’s great, but does anyone know why the code is wrong? Like do I have to add something, or is it something else?

This might be going off topic, but going from the other posts. Does this mean in vex c++ you don’t need to reference the vex namespace ?

I personally suspect the motors may be not be in the right ports or something like that. That’s why I asked about the code running as is v. with the other parts mentioned and asked if the motor port had been double checked.

Since “using namespace vex” is there, Vex C++ will use that namespace as a default when looking for things. Generally you’ll be OK doing this. You can run into problems. For example, let’s say you say “using namespace vex” and “using namespace myMotorCommands” and both of them have an identical command. Now you’ll run into trouble. But if you’d written them as vex::(whatever) v. myMotorCommands::(whatever), then that (whatever) could be identical and there wouldn’t be a problem. So, no, you won’t need vex:: on everything if you’re using Vex C++. But you will with Vex C++ Pro unless you put “using namespace vex” in there yourself.

thank you.