Loop
This node creates controllable loops with customizable iteration logic.
The Loop node provides iteration control with configurable start values, steps, and termination conditions.
The Loop node enables the creation of controlled iteration sequences. It maintains an index that can be incremented or decremented by specified steps, with configurable termination conditions for creating both ascending and descending loops.
Inputs
Loop Configuration
| Data | Description |
|---|---|
| Initial Index | Starting value for the loop index (default: 0) |
| Steps | Amount to increment/decrement each iteration (default: 1) |
| Less Than | Upper bound for ascending loops (default: 1) |
| More Than | Lower bound for descending loops (default: -1) |
Actions
| Signal | Description |
|---|---|
| Do | Starts the loop, resets index to initial value |
| Next Iteration | Advances to the next iteration |
Outputs
Current State
| Data | Description |
|---|---|
| Current Index | Current loop index value |
| Index | Alias for current index |
| Is Running | Boolean indicating if loop is active |
Events
| Signal | Description |
|---|---|
| Index Updated | Triggered when index changes |
| Loop Complete | Triggered when loop termination condition is met |
Usage
The Loop node provides flexible iteration control for various programming patterns:
Loop Types
Ascending Loop (Positive Steps)
- Index starts at Initial Index
- Increments by Steps value each iteration
- Continues while index < Less Than
- Useful for: counting up, iterating through arrays
Descending Loop (Negative Steps)
- Index starts at Initial Index
- Decrements by absolute Steps value each iteration
- Continues while index > More Than
- Useful for: counting down, reverse iteration
Example Use Cases
-
Array Processing: Iterate through array elements
Initial Index: 0
Steps: 1
Less Than: arrayLength -
Countdown Timer: Count down from a starting value
Initial Index: 60
Steps: -1
More Than: -1 -
Custom Range: Iterate over specific numeric range
Initial Index: 10
Steps: 2
Less Than: 20
Result: 10, 12, 14, 16, 18 -
Batch Processing: Process items in chunks
Initial Index: 0
Steps: 5
Less Than: totalItems
Loop Control Flow
- Initialization: Call Do signal to start loop
- Iteration: Call Next Iteration to advance
- Condition Check: Loop automatically checks termination conditions
- Completion: Loop Complete signal fires when conditions are met
Advanced Patterns
Nested Loops: Use multiple Loop nodes for nested iteration Conditional Loops: Combine with condition nodes for complex logic Dynamic Bounds: Update Less Than/More Than values during execution Event-Driven: Use Index Updated signal to trigger other operations
State Management
- Is Running: Tracks whether loop is actively executing
- Index Persistence: Current index maintained between iterations
- Reset Behavior: Do signal always resets to Initial Index
- Safety: Invalid conditions prevent infinite loops
Error Handling
The Loop node includes built-in safety mechanisms:
- Prevents infinite loops through condition validation
- Maintains state consistency during execution
- Handles edge cases like zero steps or invalid bounds
Integration Patterns
With Arrays: Use Current Index to access array elements
With Conditions: Check Index value for custom termination logic
With Delays: Add timing between iterations for visual effects
With State: Update external state based on current iteration