콘솔#
소개#
VEXcode GO 콘솔은 VEXcode 내의 콘솔 탭에 표시됩니다. 콘솔 메서드는 프로젝트 실행 중에 텍스트, 숫자 및 변수 값을 표시할 수 있습니다. 또한 콘솔 커서를 새 행으로 이동하거나, 콘솔을 지우거나, 사용자 입력을 읽거나, 색상 변경 후 출력될 텍스트 색상을 설정하거나, VEXcode의 모니터 탭에서 변수 또는 센서 값을 모니터링할 수 있습니다.
다음은 모든 방법 목록입니다.
작업 — 텍스트를 출력하거나 콘솔을 지웁니다.
게터 — 사용자 입력을 읽습니다.
input— 사용자 입력을 기다리고 응답을 텍스트로 반환합니다.
변환기 — 인쇄된 텍스트의 서식을 지정합니다.
set_print_color— 콘솔에 인쇄되는 텍스트에 사용되는 색상을 설정합니다.
모니터 — VEXcode의 모니터 탭에서 프로젝트 진행 중 센서 또는 변수의 값을 모니터링합니다.
monitor_sensor— 모니터 탭에 하나 이상의 센서 값을 추가합니다.monitor_variable— 모니터 탭에 하나 이상의 미리 정의된 변수를 추가합니다.
행위#
print#
print 은 현재 커서 위치를 사용하여 콘솔에 텍스트, 숫자 또는 변수 값을 표시합니다.
출력 메시지에 점수, 타이머 또는 센서 판독값과 같은 프로젝트의 값을 포함하려면 사용자 지정 문자열 서식을 사용하십시오. 자세한 내용은 문자열 서식 페이지를 참조하십시오.
다음 출력값이 새 행에서 시작되도록 하려면 new_line를 사용하십시오.
Usage:
console.print(value, precision)
매개변수 |
설명 |
|---|---|
|
콘솔에 표시할 텍스트, 숫자 또는 변수 값입니다. |
|
선택 사항입니다. 숫자를 출력할 때 표시할 소수점 자릿수입니다. 기본값은 |
def main():
# Display a message in the Console
console.print("Hello, robot!")
# Start threads — Do not delete
start_thread(main)

def main():
# Display 1/3 with two decimals
console.print(1 / 3, precision=2)
# Start threads — Do not delete
start_thread(main)

new_line#
new_line 은 콘솔에서 커서를 다음 행의 첫 번째 열로 이동합니다. 다음에 출력될 값은 해당 행에 나타납니다.
다음 출력값이 새 행에서 시작되도록 하려면 이 방법을 사용하십시오.
Usage:
console.new_line()
매개변수 |
설명 |
|---|---|
이 메서드에는 매개변수가 없습니다. |
def main():
# Print on two lines
console.print("Row 1")
console.new_line()
console.print("Row 2")
# Start threads — Do not delete
start_thread(main)

clear#
clear 콘솔에서 모든 행을 지웁니다.
Usage:
console.clear()
매개변수 |
설명 |
|---|---|
이 메서드에는 매개변수가 없습니다. |
def main():
# Display text, then clear it after two seconds
console.print("This will disappear...")
wait(2, SECONDS)
console.clear()
# Start threads — Do not delete
start_thread(main)
얻는 사람#
input#
input 은 사용자가 응답을 입력할 때까지 기다린 후 해당 응답을 텍스트로 반환합니다.
콘솔에 응답이 입력될 때까지 프로젝트는 input() 에서 일시 중지됩니다.
input() 에서 반환되는 값은 항상 텍스트입니다. 응답을 숫자로 사용하려면 먼저 int() 또는 float() 를 사용하여 변환하십시오.
Usage:
input()
매개변수 |
설명 |
|---|---|
이 메서드에는 매개변수가 없습니다. |
# Ask for a name, then print a greeting
answer = input("What's your name?")
console.print("Hello, " + answer)
# Ask for a number, then use it in math
answer = input("Enter a number:")
number = float(answer)
console.print(number + 1)
변이자#
set_print_color#
set_print_color 이 메서드가 사용된 후 콘솔에 출력되는 텍스트의 색상을 설정합니다. 프로젝트 시작 시 콘솔 텍스트 색상은 BLUE 으로 설정됩니다.
Usage:
console.set_print_color(color)
매개변수 |
설명 |
|---|---|
|
콘솔에 출력될 텍스트에 사용할 색상:
|
def main():
# Print text in different colors
console.print("Default text color")
console.new_line()
console.set_print_color(RED)
console.print("Red text color")
# Start threads — Do not delete
start_thread(main)

감시 장치#
monitor_sensor#
monitor_sensor 명령어를 사용하면 VEXcode의 모니터 탭에 하나 이상의 센서 값을 추가할 수 있습니다. 이를 통해 프로젝트 실행 중에 센서 값의 변화를 확인할 수 있습니다.
각 센서 값을 문자열로 제공하십시오.
Usage:
monitor_sensor(“sensor”)
monitor_sensor(“sensor1”, “sensor2”)
매개변수 |
설명 |
|---|---|
|
The sensor value to monitor, given as a string. To monitor more than one sensor value, separate each sensor value with a comma. Options include:
|
# Build Used: Super Code Base 2.0
def main():
# Monitor the rotation in the Monitor tab
monitor_sensor("drivetrain.get_rotation")
drivetrain.turn_for(RIGHT, 450)
# Start threads — Do not delete
start_thread(main)
# Build Used: Super Code Base 2.0
def main():
# Monitor the rotation and heading in the Monitor tab
monitor_sensor("drivetrain.get_rotation", "drivetrain.get_heading")
drivetrain.turn_for(RIGHT, 450)
# Start threads — Do not delete
start_thread(main)
monitor_variable#
monitor_variable VEXcode의 모니터 탭에 하나 이상의 미리 정의된 변수를 추가합니다. 이를 통해 프로젝트 실행 중에 변수 값의 변화를 모니터링할 수 있습니다.
변수를 성공적으로 모니터링하려면 전역 monitor_variable 문자열로 제공하십시오.
Usage:
monitor_variable(“variable”)
monitor_variable(“variable1”, “variable2”)
매개변수 |
설명 |
|---|---|
|
모니터링할 미리 정의된 전역 변수의 이름을 문자열로 지정합니다. 둘 이상의 변수를 모니터링하려면 각 변수 이름을 쉼표로 구분하십시오. |
# Build Used: Super Code Base 2.0
def main():
# Monitor the amount of loops
global loops
monitor_variable("loops")
# Drive in a square 3 times
for loops in range(12):
drivetrain.turn_for(RIGHT, 90, DEGREES)
drivetrain.drive_for(FORWARD, 150, MM)
# Start threads — Do not delete
start_thread(main)
actions = 0
# Build Used: Super Code Base 2.0
def main():
# Monitor the amount of loops and actions
global loops, actions
monitor_variable("loops", "actions")
# Drive in a square 3 times
for loops in range(12):
drivetrain.turn_for(RIGHT, 90, DEGREES)
drivetrain.drive_for(FORWARD, 150, MM)
actions = actions + 2
# Start threads — Do not delete
start_thread(main)