Understanding the Main Structure of a VEXcode Pro V5 Project

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.

VEXcode Pro V5 code editor showing main function with opening and closing curly braces highlighted.

The main structure is where the project execution begins. In other words, instructions containing devices, commands, and parameters are added here, the combination of which, when executed, determine specific robot behaviors.

Notice that the main structure has an opening and closing curly brace

VEXcode Pro V5 code editor showing empty space inside main function highlighted between curly braces.

An opening brace must always be paired with a closing brace.

Between the curly braces of the main structure is where you can add instructions to program your robot

VEXcode Pro V5 code editor showing vexcodeInit() line highlighted inside the main function.

Whenever you start a new program, inside the main structure is the line of code vexcodeInit();

VEXcode Pro V5 code editor showing Drivetrain.driveFor(200, mm); with device, command, and parameter sections labeled.

This command sets up and initializes all devices (e.g. motors, sensors) before your code begins. Do not delete the vexcodeInit();

In a simple project that drives the robot forward, the instruction contains three sections:

  • The device
  • The command
  • The parameters
VEXcode Pro V5 code editor showing Drivetrain.driveFor command with the dot operator highlighted between device and command.

The device and the command are separated by a period called a “ dot operator

Around the parameters of the driveFor command, there is a set of parenthesis. This is another example of paired punctuation (like the curly brace). Each parameter is separated by a comma.  

At the end of the line of code is a semicolon. The semicolon tells the compiler that this instruction is complete and should proceed to the next instruction.


VEXcode Pro V5 code editor showing two driveFor commands on separate lines with semicolons indicating execution order. Arrows are drawn to clearly show the order of instruction.

If multiple instructions are in your project, the project’s instructions will run from left to right and top to bottom.

Based on the placement of the semicolons, VEXcode Pro V5 would run the first line and then the next. It would know to move to the second line because of the semicolon.

When the project reaches the closing curly brace of the main structure, the project ends.

VEXcode Pro V5 showing the final lines of the main function. There are two driveFor commands and then the function ends with a closing curly brace.

In the project, the robot would drive forward for 200 millimeters (line 24), then drive the robot forward 50 millimeters (line 25) before the program is complete.

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

Last Updated: