Next: , Previous: Selection, Up: Control Structures


5.8.2 Simple Loops

     BEGIN
       code1
       flag
     WHILE
       code2
     REPEAT

code1 is executed and flag is computed. If it is true, code2 is executed and the loop is restarted; If flag is false, execution continues after the REPEAT.

     BEGIN
       code
       flag
     UNTIL

code is executed. The loop is restarted if flag is false.

Programming style note: To keep the code understandable, a complete iteration of the loop should not change the number and types of the items on the stacks.

     BEGIN
       code
     AGAIN

This is an endless loop.