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.
Örnek: Bir robotun düz bir mesafe gitmesi için örnek program
Aşağıdaki fonksiyon robotuntotalEnckodlayıcı için ileri doğru koşmasına olanak sağlayacaktır. V5 Clawbot yapılandırmasını kullanır.
BuspinToPositionişlevi, hareket tamamlanana kadar geri dönmeyecektir. Buna "senkronize" eylem adı verilir ve son parametre olantruetarafından belirlenir.
Kullanıcı tanımlı bir işlevi kullanmadan:
int main() {
vexcodeInit();
LeftMotor.resetPosition ();
LeftMotor.setVelocity(100,0, yüzde);
LeftMotor.spinToPosition(500,0, derece, doğru);
Brain.Screen.printAt(5,30, "secs rev deg" );
Brain.Screen.printAt(5,60, "%.2f: %8.2f %8.2f",
Brain.Timer.value(),
LeftMotor.position(rev),
LeftMotor.position(deg));
bekle(1000, msn);
LeftMotor.resetPosition ();
LeftMotor.setVelocity(-100,0, yüzde);
LeftMotor.spinToPosition(-1000.0, c, true);
Brain.Screen.printAt(5,100, "secs rev deg");
Brain.Screen.printAt(5,130, "%%.2f: %8.2f %8.2f",
Brain.Timer.value(),
LeftMotor.position(rev),
LeftMotor.position(deg));
bekle(1000, msn);
}
Örnek aşağıdaki sonucu verebilir:
saniye ham devir derecesi 2,06 5445 3,12 1089
Testinizin ondalık basamaklarda çok küçük bir farkla değişeceğini unutmayın.
Kullanıcı tanımlı bir fonksiyonla:
Aşağıdaki örnek, bir dizi işlemin tek bir yeniden kullanılabilir "işlev" çağrısında nasıl yakalanacağını gösterir.
void reportMotionValues() {
Brain.Screen.printAt(5, 60, "%.2f: %8.2f %8.2f",
Brain.Timer.value(),
LeftMotor.position(rev),
LeftMotor.position(deg));
}
int main() {
vexcodeInit();
LeftMotor.resetPosition();
LeftMotor.setVelocity(50,0, yüzde);
LeftMotor.spinToPosition(500,0, derece, doğru);
reportMotionValues();
LeftMotor.resetPosition ();
LeftMotor.setVelocity(-50,0, yüzde);
LeftMotor.spinToPosition(-500,0, derece, doğru);
reportMotionValues();
}
Burada çağıran işlevi main()'dan gelen mantık akışının sırası gösterilmektedir: