Console#
Introduction#
The console is used to display text output from a VEX V5 C++ project.
In VEXcode V5, console output appears in the Monitor window.
In VS Code, console output appears in the Terminal.
When a new project begins running, the cursor starts at row 1 of the console.
Functions#
The following functions can be used to print text in the console:
printf– Print text to the console.
printf#
Prints text on the screen using the current cursor position.
Available Functionsvoid printf(const char *value);
Parameter |
Type |
Description |
|---|---|---|
|
|
The string (in quotations) or integers to print to the console. |
This function does not return a value.
NotesText will not be sent to the console until a new line is started.
// Print a message to the console
printf("Hello, robot!");
// Print a new line to the console
printf("\n");
Control Sequences#
The console supports ANSI control sequences for formatting and screen control.
Clear console — Clears all text from the console.
Change the Font Color — Changes the text color.
Clear console#
By printing \033[2J, everything inside the console will be cleared.
// Print to the console, then clear it after
// 2 seconds
printf("VEXcode");
wait(2, seconds);
printf("\033[2J\n");
Change the Font Color#
You can change what color the font will be when printing to the console by using the following sequences:
\033[30m— Black\033[31m— Red\033[32m— Green\033[33m— Yellow\033[34m— Blue\033[35m— Purple\033[36m— Cyan\033[37m— White\033[91m— Orange\033[97m— Transparent
All color codes need to follow an escape sequence
\033in order to function.
// Print VEXcode in Red to the console
printf("\033[31mVEXcode");
// Set the console text color to Red before printing
printf("\033[31m");
printf("VEXcode");