Control#

Introduction#

The Control blocks in VEXcode 123 manage the flow of a project by handling loops, conditions, delays, and stopping execution.

Below is a list of available blocks:

  • wait – Pauses execution for a specific duration.

  • wait until – Pauses execution until a specified condition is met.

  • repeat – Repeats enclosed blocks a specific number of times.

  • forever – Repeats enclosed blocks indefinitely.

  • repeat until – Repeats enclosed blocks until a condition is met.

  • while – Repeats enclosed blocks while a condition remains true.

  • if – Runs enclosed blocks if a condition is true.

  • if / else – Runs one set of blocks if a condition is true, otherwise runs another.

  • if / else if / else – Runs different sets of blocks depending on multiple conditions.

  • break – Exits a repeat, forever, repeat until, or while loop immediately.

  • stop project – Ends the execution of the project.

wait#

The wait block pauses for a specific amount of time before moving to the next block.

wait stack block#
esperar (1) segundos

Parameters

Description

time

The amount of time to wait, as a positive integer or decimal in seconds.

Example

aria-description goes here#
cuando empezó :: hat events
[Drive forward then stop.]
unidad [adelante v]
esperar (2) segundos
deja de conducir

wait until#

The wait until block pauses execution until a specified condition is met before proceeding to the next block.

wait until stack block#
esperar hasta <>

Parameters

Description

condition

The condition that must be met before moving on to the next block.

Example

aria-description goes here#
cuando empezó :: hat events
[Drive forward when the sound button is pressed.]
esperar hasta <[soundIcon v] presionado?>
conducir [adelante v] por [200] [mm v]

repeat#

The repeat block runs the blocks inside it a set number of times.

repeat c block#
repetir [10]
fin

Parameters

Description

times

A whole number that sets how many times the repeat block runs.

Example

aria-description goes here#
cuando empezó :: hat events
[Drive in a square pattern.]
repetir [4]
conducir [adelante v] por [200] [mm v]
girar [derecha v] por [90] grado

forever#

The forever block keeps running the blocks inside it again and again without stopping.

forever c block#
para siempre
fin

Parameters

Description

This block has no parameters.

Example

aria-description goes here#
cuando empezó :: hat events
[Blink LED light in a pattern.]
para siempre
resplandor [verde v]
esperar [0.5] segundos
resplandor [apagado v]
esperar [0.5] segundos

repeat until#

The repeat until block executes the enclosed blocks repeatedly while the condition evaluates as False.

repeat until block#
repetir hasta <>
fin

Parameters

Description

condition

An expression or variable that is evaluated before each iteration. If it evaluates as:

  • False - The loop continues
  • True - The loop stops

Example

aria-description goes here#
cuando empezó :: hat events
[Blink LED light until the sound button is pressed.]
repetir hasta <[soundIcon v] presionado?>
resplandor [verde v]
esperar [0.5] segundos
resplandor [apagado v]
esperar [0.5] segundos

while#

The while block executes the enclosed blocks repeatedly while the condition evaluates as True.

while c block#
mientras <>
fin

Parameters

Description

condition

An expression or variable that is evaluated before each iteration. If it evaluates as:

  • True - The loop continues
  • False - The loop stops

Example

cuando empezó :: hat events
[Turn the robot around.]
mientras <(rumbo de la unidad en grados) [math_less_than v] [180]>
turno [derecha v]
fin
deja de conducir

if#

The if block executes the enclosed block of code if the condition evaluates as True.

if block#
si <> entonces
fin

Parameters

Description

condition

An expression or variable that is evaluated when the statement runs. If it evaluates as:

  • True - The code inside the if block executes
  • False - The block is skipped

Example

aria-description goes here#
cuando empezó :: hat events
[Drive forward whenever the sound button is pressed.]
para siempre
si <[soundIcon v] presionado?> entonces
conducir [adelante v] por [200] [mm v]

if / else#

The if / else block determines which enclosed block of code runs based on whether the condition evaluates as True or False.

if then else block#
si <> entonces
demás
fin

Parameters

Description

condition

An expression or variable that is evaluated when the statement runs. If it evaluates as:

  • True - The code inside the if block executes
  • False - The code inside the else block executes instead

Example

aria-description goes here#
cuando empezó :: hat events
[Drive forward until a crash.]
para siempre
si <¿Se detectó un accidente?> entonces
deja de conducir
demás
conducir [adelante v] por [200] [mm v]

if / else if / else#

The if / else if / else block structure selects which enclosed block of code runs based on conditions:

  • if runs its block of code if the condition evaluates as True.

  • else if checks additional conditions only if all previous conditions evaluated as False. Multiple else if statements can be used.

  • else runs its block of code only if none of the previous conditions evaluated as True.

if else if else block#
si <> entonces
de lo contrario si <> entonces
demás
fin

Parameters

Description

condition

An expression or variable that is evaluated when the statement runs. The first condition that evaluates as:

  • True - Determines which block of code executes
  • False - If none are True, the else block of code runs

Example

aria-description goes here#
cuando empezó :: hat events
[Turn right for the right button, left for the left button.]
para siempre
si <[ifbuttonright v] presionado?> entonces
turno [derecha v]
de lo contrario si <[ifbuttonleft v] presionado?> entonces
turno [izquierda v]
demás
deja de conducir

break#

The break block exits a loop immediately.

break stack block#
romper

Parameters

Description

This block has no parameters.

Example

aria-description goes here#
cuando empezó :: hat events
[Flash the LED until the sound button is pressed.]
para siempre
resplandor [verde v]
esperar [0.5] segundos
resplandor [azul v]
esperar [0.5] segundos
si <[soundIcon v] presionado?> entonces
romper

stop project#

The stop project block ends a running project.

stop project block#
detener el proyecto

Parameters

Description

This block has no parameters.

Example

aria-description goes here#
cuando empezó :: hat events
[Stop the project after a crash.]
para siempre
unidad [adelante v]
si <¿Se detectó un accidente?> entonces
detener el proyecto