A loop condition is a test that
is part of the DO WHILE
statement.
DO WHILE
statementLook at the following program:
' Loop with a loop condition ' LET COUNT = 0 'Statement 1 ' DO WHILE COUNT <= 5 'Statement 2 PRINT COUNT 'Statement 3 LET COUNT = COUNT + 1 'Statement 4 LOOP END
Here the DO WHILE
in statement 2 is
the loop condition (the gate keeper).
Execution enters the loop body only if
COUNT <= 5
that is, only if the number stored in COUNT
is less than or equal to 5.
Then statements 3 and 4 are executed,
and then
LOOP
sends execution back to the DO WHILE
.
The test COUNT <= 5
Say that Statement 4 has just changed COUNT
to 5.
Now the LOOP
statement sends execution back
to the DO WHILE
.
Will the loop body execute again?