for range loop_basic(Args{iterations: 3}) {
send_text_message(Args{channel_id: trigger.channel_id, message_content: "Next item"})
}
Loop
LoopLogic
Run the nested blocks a fixed number of times.
- Loop block: the blocks placed inside it run once for each item, and can use the current item's outputs.
Inputs
IterationsRequired
Number of times to run the loop body.
Example: 3
Loop Body
Blocks to run each iteration.
Holds blocks
Outputs
Current Iteration
1-based index of the current loop run.
Example: 1
Total Iterations
Total number of times this loop will run.
Example: 5
Build a bot using blocks like Loop
Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.
Advanced Documentation
This documentation can be useful when using code mode. View as Markdown
ID:
loop_basic- Loop block: write
for item := range loop_basic(Args{...}) { ... }and read the current item's outputs fromitem. See loops.
Inputs
| Field | InventScript name | Value |
|---|---|---|
| Iterations | iterations | e.g. "3" |
| Loop Body | body | blocks: func() { ... } |
Outputs
| Field | InventScript name | Value |
|---|---|---|
| Current Iteration | current_iteration | e.g. "1" |
| Total Iterations | total_iterations | e.g. "5" |
Example InventScript
More logic blocks
While LoopRepeat blocks while a condition is true.If StatementCompare two values and run different blocks based on the result.Advanced ConditionalRun different blocks based on grouped comparisons.Conditional ValueCompare two values and output one of two values based on the result.FolderOrganize blocks into a folder. Creates a variable scope.BreakStop the current loop and continue with the blocks after it.ContinueSkip the rest of this loop iteration and move to the next one.Exit FlowStop the entire flow immediately. No further blocks will run.Call Custom BlockCall a custom block and use its returned outputs.ReturnReturn outputs from the current custom block and stop executing it.