Creating Variables in VEXcode Pro V5

The VEX Visual Studio Code Extension has replaced VEXcode Pro V5, which is now end-of-life.

VEXcode Blocks and VEXcode Text remain actively developed and supported for all VEX platforms.

What are Variables?

Variables are like containers that store something. Each container “type” possesses a set of properties including size, and what kind of content it can hold.

Two attributes that you should know:

Types

Each variable must have a “type.” This article will cover only the primitive types - char, short, int, long, long long, float, and double.

The primitive data type can hold only scalar values, no dimension to it. Choosing the right type is critical as the type affects how the variable is stored.

Declarations

Variables must be declared/created before you can use it.

e.g.

int height;
float amount;

Initialization means pre-populating the variable with an initial value:

e.g.

height = 5.0;
amount = 0.0;

Or, you can do both declaration and initialization together:

int height = 5.0;
float amount = 0.0;

Sample:

int length=5, width=10;
Brain.Screen.print("Perimeter of a %d by %d rectangle = %d",
length, width, (length + width)*2 );

Sample to show issues with something not initialized:

Code snippet demonstrating programming concepts in V5, showcasing syntax and structure relevant to the V5 Category Description.

Sample to show invalid declaration:

Code snippet illustrating a programming example in V5, showcasing syntax and structure for developers.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: