VEXcode Pro V5의 제어 구조 이해

The VEX Visual Studio Code Extension has replaced VEXcode Pro V5, which is now end-of-life.

VEXcode Blocks and VEXcode Text remain actively developed and supported for all VEX platforms.

개별 명령 외에도 프로젝트에서 제어 구조를 사용하여 프로그램 흐름을 제어할 수도 있습니다.

이 기본 구조는 제어 구조의 예입니다. Main 프로젝트가 시작되어야 하는 위치를 표시하여 프로그램 흐름을 제어합니다. 제어 구조는 일반적으로 세미콜론 대신 중괄호를 사용합니다.

#include "vex.h"

using namespace vex;

int main() {
  // 로봇 구성 초기화. 제거하지 마세요!
  vexcodeInit();
  // 로봇이 시계 방향으로 회전하고 "It is true and the loop continues!"를 표시하는 루프
  while(true){
    Brain.Screen.print("참입니다. 루프가 계속됩니다!");
    LeftMotor.spin(forward);
    RightMotor.spin(reverse);
  }

}

또 다른 유형의 제어 구조는 while 루프입니다. while 루프 은 while 루프의 조건이 참인 동안 중괄호 사이의 코드를 반복합니다.


while 루프의 조건이 더 이상 참이 아니면 프로그램 흐름은 while 루프를 종료합니다.  

프로그램 흐름은 기본 구조의 모든 명령을 계속 실행합니다. 남은 명령이 없기 때문에 프로그램 흐름은 기본 구조의 닫는 중괄호에 도달하여 이 프로젝트가 종료됩니다.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: