Loop

Command

Not Applicable

Description

The Loop block iterates over a list of blocks a fixed number of times. The number of times can be a provided constant or a numerical expression. The loop block includes a Yield at the end making the maximum loop rate the controller sample rate.

Escapes

The Loop block does not produce any escapes.

Examples

Clicking on the numeric field provides a keypad to enter the number of iterations. Note that this is an integer keypad since the value has to be a whole number:

This block list performs 5 individual moves with a 1/2 second delay between each one:

This block list writes ascending values into a list.

This block list makes the number of parts indicated in an editor:

However checking with the editor control every loop takes a small amount of time. If this was a time critical loop it would be better to copy the editor value into a variable and then work directly with the variable as the loop count:

Related Topics

While
Repeat Until
Yield