控制台#

简介#

The VEXcode AIM Console is displayed in the Console Tab within VEXcode. Console blocks can display text, numbers, and variable values while a project is running.

Below is a list of all available blocks:

将光标设置到控制台上的下一行#

The set cursor to next row on console stack block moves the cursor to column 1 on the next row in the Console. The next value printed will appear on that row.

Use this block when you want the next printed value to start on a new row. If this block is not used, and the previous print on console block was not expanded to include and set cursor to next row, the next printed value will appear immediately after the previous value on the same row.

set cursor to next row on console stack block#
set cursor to next row on console

参数

描述

该指令块没有参数。

示例

When started, prints ‘Row 1’ on the Console, moves the cursor to the next row, and then prints ‘Row 2’.#
when started
[Display two lines of text.]
print [Row 1] on console ▶
set cursor to next row on console
print [Row 2] on console ▶

The VEXcode Console, showing the Console and the text "Row 1" displayed on the first line and "Row 2" on the second line.

清除控制台#

The clear console stack block clears all rows from the Console and moves the cursor back to the first row.

clear console stack block#
clear console

参数

描述

该指令块没有参数。

示例

when started
[Clear the Console after printing.]
print [This will disappear...] on console ▶
wait [2] seconds
clear console

询问、等待和应答#

The ask and wait stack block displays a message in the Console and pauses the project until a response is entered into the Console.

The answer reporter block returns the most recent response entered in the Console. The response is returned as text. To use the response as a number, use the convert reporter block to convert the answer to a number first.

询问并等待指令块。#
ask [What's your name?] and wait

参数

描述

提示

The message to display in the Console.

应答指令块。#
answer

参数

描述

该指令块没有参数。

示例

when started
[Tell the robot your name.]
ask [What's your name?] and wait
print [Hello, ] on console ▶
print (answer) on console ▶

在控制台上设置打印精度#

The set print precision on console stack block sets how many decimal places are displayed when numbers are printed in the Console. This setting applies to numbers printed after this block is used. At the start of a project, print precision is set to 1, so numbers print with no decimal places.

set print precision on console stack block#
set print precision to [0.1 v] on console

参数

描述

精度

The print precision to use:

  • 1
  • 0.1
  • 0.01
  • 0.001
  • All Digits

示例

当程序启动时,将打印精度设置为两位小数,并在控制台上将 1/3 打印为 0.33。#
when started
[Print 1/3 as 0.33.]
set print precision to [0.01 v] on console
print ([1] [math_division v] [3]) on console ▶

The VEXcode Console, showing the Console and the text "0.33" displayed.

在控制台上设置字体颜色#

The set font color on console stack block sets the font color used for text printed in the Console. At the start of a project, the font color is set to blue.

The set font color on console stack block.#
set font color to [red v] on console

参数

描述

颜色

The font color to use for text printed in the Console:

  • red
  • green
  • blue
  • black
  • white
  • yellow
  • orange
  • purple
  • cyan

示例

when started :: hat events
[Print text in different colors.]
print [Default text color] on console ▶
set cursor to next row on console
set font color to [red v] on console
print [Red text color] on console ▶

The VEXcode Console, showing the Console and blue-colored text saying "Default text color" displayed on the first line and red-colored "Red text color" on the second line.