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#
- The loop starts when the
Executeinput is triggered. - For each number from
First IndextoLast Index(inclusive), the node: - Sets theIndexoutput to the current number. - Triggers theBodyexecution output. - After the loop finishes, the
Completedexecution output is triggered.
Breaking the Loop#
- Triggering the
Breakinput will stop the loop before the next iteration begins. - The
Completedoutput 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 Indexis0andLast Indexis9, the loop will run 10 times (for indices 0 through 9). - If
First IndexandLast Indexare both0, the loop will run once. - If
Last Indexis less thanFirst Index, the loop body will not execute, butCompletedwill be triggered immediately.
Inputs#
| Port | Description |
|---|---|
| Starts the loop. | |
| Stops the loop before the next iteration begins. | |
| The starting index for the loop. | |
| The final index for the loop (inclusive). |
Outputs#
| Port | Description |
|---|---|
| Executes on each iteration of the loop. | |
| The current iteration index. | |
| Executes once the loop has finished or been broken. |
ID: core/for-loop@v1