Loops
Loop blocks repeatedly execute code, eliminating the need to duplicate instructions. Use loops to process multiple sensor readings, generate patterns, handle collections of data, or create sequences of operations.
repeat

Executes the enclosed code a fixed number of times. Use this when you know exactly how many iterations you need.
Parameters:
Count (Number): Number of times to repeat
Example:

repeat while

Repeats code as long as the condition remains true. The condition is checked before each iteration.
Parameters:
Condition (Boolean): The condition to evaluate before each iteration
Example:

repeat until

Repeats code until the condition becomes true. The condition is checked after each iteration, so the loop always executes at least once.
Parameters:
Condition (Boolean): The condition to evaluate after each iteration
Example:

iterator

Returns the current iteration counter for the loop, starting from 0. Use this to create indexed operations or patterns.
Returns:
Number: The current loop iteration (0, 1, 2, ...)
Example:

This block only works inside a loop block. Using it elsewhere will cause an error.

Last updated