Difference between revisions of "Loop Icon Properties"
| Line 1: | Line 1: | ||
| − | + | [[File:iconLoop.png|border]] | |
| − | + | ||
| − | + | Loop icons are used to repeat a task until specified conditions are fulfilled, or to perform the loop a set number of times. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| Line 22: | Line 17: | ||
| − | + | ==Details== | |
| − | == | + | {| style="margin:0px; text-align:center;" |
| − | + | |- | |
| − | + | |[[File:iconLoop.png|border]] | |
| + | | width="50px" |→ | ||
| + | |[[File:Gen_Loop_Flowchart_Icon.png]] | ||
| + | |width="50px" |→ | ||
| + | |[[File:Properties-loop.png]] | ||
| + | |} | ||
==Loop types== | ==Loop types== | ||
| Line 47: | Line 47: | ||
| − | == | + | ==Properties== |
'''Display Name''' | '''Display Name''' | ||
Latest revision as of 16:28, 11 June 2026
Loop icons are used to repeat a task until specified conditions are fulfilled, or to perform the loop a set number of times.
Contents
Old Versions
This page is current for Flowcode v11 and later. Earlier versions can be found below:
| Flowcode v10 |
| Flowcode v9 |
| Flowcode v8 |
Details
| → | → |
|
Loop types
There are several types of loop as explained below.
Loop forever
Creates an infinite loop where the icons between the start and end of this loop icon are repeated forever. Many embedded programs require an infinite loop because the code running in the microcontroller will never stop. In versions of Flowcode prior to v11, a condition "While 1" would have been used instead to create an infinite loop.
Loop while
A "while" loop will repeat the icons if the test in the "expression" box is true. This expression can be tested at the start or at the end of the loop and it is at this point that the program decides to continue or abort the loop.
Loop until
An "until" loop is similar to the "while" loop, but this time the loop will repeat until the test in the "expression" box becomes true. Again, this can be tested at the beginning or the end of the loop.
Loop count
This allows a loop to be repeated a set number of times. The number of times to repeat is entered in the "count" box. Note that this value will usually be a constant or a literal value (e.g. "5").
An internal counter will be set to zero when the loop first begins and will be automatically incremented at the end of each loop iteration. At the beginning of each loop, this internal counter will be checked to see if it is less than the value of the "count", and if it is not then the loop will be aborted.
This internal counter can be set to an existing variable instead using the Count using a variable option. This will expose the number of iterations around the loop to the code within the loop start and end icons. This variable will show a value of "0" during the first loop iteration, "1" in the second loop iteration, etc.
Properties
Display Name
The name of the icon that appears on the flowchart.
Expression
The expression used to determine if the loop should continue or end. This is used by "while" and "until" versions of the loop command.
For a "while" loop, this loops the program while the specified condition is true.
For an "until" loop, this loops the program until the specified condition becomes true.
The expression is tested at the beginning or the end of the loop.
Variables Arrow
Clicking on the down arrow brings up the variables dialog window allowing you to select an existing variable or to create a new one.
Test the loop at the:
Select whether you wish the loop's expression to be tested at the start or at the end of the loop. Testing at the end of the loop means that the code within the loop is guaranteed to execute at least once.
Loop count
Sets the loop to loop through a set number of iterations. The value should usually be a whole number between 1 and 99999999.
Note that a variable can be used for the "count" rather than a constant value. But be aware because changing the value of this variable within the loop could cause odd behaviour and make your program's execution difficult to predict.
Count using a variable
Allows an existing variable to be used as the count variable. When active, this resets the count variable to 0 when the loop first begins and automatically increments the variable at the end of each loop iteration. It is best that the value of this variable should not be altered within the loop by user code, otherwise the loop may behave unexpectedly.
Video
See the Loop icon video to see how this icon is used in a project.
