VCS Coding Bugs

Hello, engineering teacher here trying to figure out how to teach students to use the new VCS C++ programming language. I have very little background in programming, but in talking with coworkers who are CS majors, it seems like there are a few bugs:

  1. Printing a percent symbol (%) does not work like expected. The VCS Command Reference site has the following sample code:

Brain.Screen.printAt(1, 20, “Battery Capacity: %d%%”, Brain.Battery.capacity());

But I had to use four % symbols in a row to get it to print to the brain screen. So my code looked like:

Brain.Screen.printAt(1, 20, “Battery Capacity: %d%%%%”, Brain.Battery.capacity());

Next, and probably the more important one, I realized that you don’t need to write out the full hierarchy for the different classes/functions (sorry, don’t know correct terminology) for most lines of code. For example, you can write:

LeftMotor.spin(directionType::fwd, 50, velocityUnits::pct);


LeftMotor.spin(fwd, 50, pct);

Both worked. The second might be easier to teach students, but unfortunately you can’t always delete that first part with the double colon after it. I noticed it doesn’t work with:

task::sleep(1000); //so you can’t just write “sleep(1000);”


Sonar1.distance(distanceUnits::mm) //can’t remove “distanceUnits::”

Thoughts? Any other “bugs” you’ve noticed?

In future, wrap your code in triple backtics (```) or [code] … [/code] tags to get code formatting.

This doesn’t really seem like a bug, just a result of how scope resolution works in c++. If you really want to get around this you can use #define preprocessor statements at the top of your program, e.g.:

#define sleep(n) task::sleep(n)
#define mm distanceUnits::mm 


1 Like

Like @holbrook was saying, these aren’t bugs. (The issue with the %'s might be a bug.) The vex namespace (in both VEX’s C++ offerings and Robot Mesh Studio’s C++) includes some shorthand for commonly used enums like fwd and pct. It’s not that you can omit directionType or velocityUnits sometimes by the rules of the language, it’s more that the API somewhere says:

namespace vex {
    const directionType fwd = directionType::fwd;
    const percentUnits pct = percentUnits::pct;

This allows the use of the shorthand you’ve noticed. (After the line using namespace vex;) You could do the same for static methods that you want to use, like sleep, but that would require a function pointer rather than just a value assignment:

void (*const sleep)(double) = task::sleep; //argument type might be incorrect

You could also just wrap it in a function of your own:

void sleep(double time) { //argument type might be incorrect