Consola#

Introducción#

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 Functions
void printf(const char *value);

Parameters

Parameter

Type

Description

value

const char*

The string (in quotations) or integers to print to the console.

Return Values

This function does not return a value.

Notes
  • Text 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#

By printing \033[2J, everything inside the console will be cleared.

Examples
// 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

Notes
  • All color codes need to follow an escape sequence \033 in order to function.

Examples
// Print VEXcode in Red to the console
printf("\033[31mVEXcode");

// Set the console text color to Red before printing
printf("\033[31m");
printf("VEXcode");