Skip to content

For Loop

Executes a block of nodes for a specified number of iterations.

This node provides a classic 'for loop' construct. It iterates from a First Index to a Last Index, executing the nodes connected to the Body output on each iteration.

Execution Flow#

  1. The loop starts when the Execute input is triggered.
  2. For each number from First Index to Last Index (inclusive), the node: - Sets the Index output to the current number. - Triggers the Body execution output.
  3. After the loop finishes, the Completed execution output is triggered.

Breaking the Loop#

  • Triggering the Break input will stop the loop before the next iteration begins.
  • The Completed output will still be triggered after a break.

Iteration Count#

The loop is inclusive. The number of iterations is Last Index - First Index + 1.

  • If First Index is 0 and Last Index is 9, the loop will run 10 times (for indices 0 through 9).
  • If First Index and Last Index are both 0, the loop will run once.
  • If Last Index is less than First Index, the loop body will not execute, but Completed will be triggered immediately.

Inputs#

Port Description
Execute
Starts the loop.
Break
Stops the loop before the next iteration begins.
First Index
The starting index for the loop.
Last Index
The final index for the loop (inclusive).

Outputs#

Port Description
Body
Executes on each iteration of the loop.
Index
The current iteration index.
Completed
Executes once the loop has finished or been broken.

ID: core/for-loop@v1