|
A WHILE loop repeatedly executes a sequence of instructions — called its body — while a given Boolean condition holds. The logical condition is an entry condition i.e. it is tested each time before the body is going to be executed. If the condition expression is false on entering the loop element (the first time) then the loop body will not be executed at all.
The text to be filled in on adding a WHILE element is a Boolean expression, i.e. the logical condition. This may be a comparison, a variable with Boolean content, or several conditions combined by logical operators (see more details under IF statement). Please note: The default text can be modified under Preferences › Structures.
This is how you add a WHILE loop to your diagram:
1. Click on the WHILE loop symbol in the toolbar (having selected the element, after which the WHILE loop is to be inserted):
 2. Write a condition (a Boolean expression) into the text field:
3. Add instructions (i.e. the actions to be repeated while the condition is being true — it may of course also be elements of any other kind) into the loop body:
(The little red triangle in the loop element as shown above is just to call your attention to a related Analyser warning in the Report list at the bottom. Since version 3.30-14.)
4. If you want more than one instruction executed the just add them after or before the first one:

5. If you want to add further instructions after the entire WHILE-Loop you must select the head first:

6. This is what the finished version looks like:

Download this Demo
Download other Demo (Newton's square root)
|