for loop := range while_loop(Args{
value_1: "hello",
condition: "less than (<)",
value_2: 5,
}) {
send_text_message(Args{channel_id: trigger.channel_id, message_content: "Result: " + loop.result})
}
While Loop
LoopLogic
Repeat blocks while a condition is true.
Loops cannot exceed 5,000 iterations.
- Loop block: the blocks placed inside it run once for each item, and can use the current item's outputs.
Inputs
Value 1Required
The first value to compare.
Example: hello
ConditionRequired
The comparison operator.
Optionsequals (=)equals (case insensitive)equals (numeric)equals (float)does not equal (!=)does not equal (case insensitive)greater than (>)greater than (float)less than (<)less than (float)greater or equal (>=)greater or equal (float)less or equal (<=)less or equal (float)containscontains (case insensitive)does not containdoes not contain (case insensitive)is in the comma-separated listis in the comma-separated list (case insensitive)is not in the comma-separated listis not in the comma-separated list (case insensitive)starts withstarts with (case insensitive)does not start withdoes not start with (case insensitive)ends withends with (case insensitive)does not end withdoes not end with (case insensitive)is emptyis not empty
Value 2Required
The second value to compare.
Example: 5
Loop Body
Blocks to run each iteration.
Holds blocks
Outputs
Current Iteration
1-based index of the current loop run.
Example: 1
Result
Whether the condition evaluated to true or false.
Example: true
Build a bot using blocks like While 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:
while_loop- Loop block: write
for item := range while_loop(Args{...}) { ... }and read the current item's outputs fromitem. See loops.
Inputs
| Field | InventScript name | Value |
|---|---|---|
| Value 1 | value_1 | e.g. "hello" |
| Condition | condition | "equals (=)", "equals (case insensitive)", "equals (numeric)", "equals (float)", "does not equal (!=)", "does not equal (case insensitive)", "greater than (>)", "greater than (float)", "less than (<)", "less than (float)", "greater or equal (>=)", "greater or equal (float)", "less or equal (<=)", "less or equal (float)", "contains", "contains (case insensitive)", "does not contain", "does not contain (case insensitive)", "is in the comma-separated list", "is in the comma-separated list (case insensitive)", "is not in the comma-separated list", "is not in the comma-separated list (case insensitive)", "starts with", "starts with (case insensitive)", "does not start with", "does not start with (case insensitive)", "ends with", "ends with (case insensitive)", "does not end with", "does not end with (case insensitive)", "is empty", "is not empty" |
| Value 2 | value_2 | e.g. "5" |
| Loop Body | body | blocks: func() { ... } |
Outputs
| Field | InventScript name | Value |
|---|---|---|
| Current Iteration | current_iteration | e.g. "1" |
| Result | result | e.g. "true" |
Example InventScript
More logic blocks
LoopRun the nested blocks a fixed number of times.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.