- 13 Feb 2023
- 1 Minute to read
- Contributors
- Print
- DarkLight
- PDF
Loops Component
- Updated on 13 Feb 2023
- 1 Minute to read
- Contributors
- Print
- DarkLight
- PDF
The Loops component is primarily used to perform operations repeatedly in the form of iterations.
While Block
The While statement loops through a block of code as long as a specified condition is true. The do while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.
Input | Output | Block Layout | Generated Code |
---|---|---|---|
Choose the repeater type (while or until), Boolean (True or False), The repeater statement. | For while repeater, it will execute the statement until it becomes false. For until repeater, it will execute the statement until it becomes true. |
|
For Block
The For loop loops through a block of code a number of times.
Input | Output | Block Layout | Generated Code |
---|---|---|---|
Variable or number for: (from)input-1,(to)input-2, and (by)input-3 Any code block within "do" statement | For the count repeater, it will execute the given statement block based on "from-to" input values and the step(by) value. We can have high to low or low to high. |
| |
Table variable(array) in list, Any code block within "do" statement | In for each repeater, it will execute till the given list length. It will also give each list value to a variable. |
|
Repeater Block
The Repeater block is used to execute the "do" statement block for a selective number of times. They can be used within the For and While loops.
Input | Output | Block Layout | Generated Code |
---|---|---|---|
Variable or Number The repeater statement. | The repeater will execute the given statement for a fixed number of times. |
|
Break or Continue Block
The Break statement is used to jump out of a loop. It can be used within any of the loops. (Mostly Break and Continue statements are used within While Loops)
The Continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.
Input | Output | Block Layout | Generated Code |
---|---|---|---|
NA | It will break out of the repeater or continue to the next iteration. |
|