Manual – IPOSplus®
201
16
do...while
Compiler – Constructions
First, the statement is performed. As a statement block, it may also contain several
statements. This is followed by the test of whether the expression has the value TRUE
(not equal to zero) or FALSE (equal to zero). If the value is TRUE, the statement is per-
formed again, otherwise the loop is exited.
The expression can also be made up of several logically interlinked conditions.
In contrast to the while loop, the statement is always performed at least once in the do
while loop.
Example
The statements within the block are carried out as long as H1 is greater than 5. H2 gets
the value 4 when the loop breaks off.
If the expression always remains TRUE, the result is an endless loop:
In this case, the expression has the value 1, which means that the loop is never broken.
This loop can be broken off using the break statement.
In this example, the do loop is broken off using the break statement if the value of the
IPOS
plus®
variable H2 is greater than 20.
INFORMATION
Potential problem: The while (...); line always ends with a semicolon.
H2 = 0;
H1 = 10;
do
{
H2 = H2 +1;
H1 = H1 -1;
} while ( H1 > 5 );
do
H2 = H2 +3;
while ( 1 );
H2 = 0;
do
{
H2 = H2 +3;
if ( H2 > 20 )
break;
} while ( 1 );
P
i
f
kVA
Hz
n
P
i
f
kVA
Hz
n