Console#

Introduction#

All Console methods will appear in the VEXcode AIR Console. To view the Console, the Console Serial Port must be connected. Console methods allow you to display text, receive input, and format printed data in real time in VEXcode AIR.

Below is a list of the available methods for interacting with the console:

Actions – Output text or clear the console.

  • print – Displays text at the current cursor position.

  • clear_console – Clears all text from the Console.

Getter – Read user input.

  • input – Returns the most recent user input as a string.

Mutator – Format printed text.

Actions#

print#

print displays text in the Console with the current set_console_text_color. Each use of print moves the cursor to the next line by default.

Usage:
print(value, end)

Parameter

Description

value

The text that will be printed as a string.

end

Optional. The string added to the end of the printed text. Specified as end=. Default: end=“\n”, which is automatically hidden and moves the cursor to the next line.

# Display two messages consecutively
print("I'm printed on one line.")
print("I'm printed automatically on the next line!")

Displays the two messages being displayed consecutively in the Print Console.

# Print three colors on one line in the Mission Logs
colors = ["Red", "Green", "Blue"]

for color in colors:
    print(color, end=", ")

Displays three colors being printed one after the other on one line.

clear_console#

clear_console will clear all text from the Console.

Usage:
clear_console()

Parameters

Description

This method has no parameters.

# Clear a Console message after 2 seconds.
print("I will be cleared!")
wait(2, SECONDS)
clear_console()

Getter#

input#

input returns what is sent to the drone from the Console as a string.

Usage:
input()

Parameters

Description

This method has no parameters.

# Message the drone a name for the drone to greet
print("What is your name?")
answer = input()
print("Hi, " + answer + "! My name is AIR.")

Displays a greeting as the drone greets VEX, as VEX was the name used in the input.

Mutator#

set_console_text_color#

set_console_text_color sets the color of all subsequent print commands.

Usage:
set_console_text_color(color)

Parameter

Description

color

The color to set:

  • BLACK
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE
  • YELLOW

# Display a green message on the Console
set_console_text_color(GREEN)
print("I am green!")

Displays a message with green text.