DOW (do while) is used for loops with conditions that defines for how long the loop should continue.
ENDDO or END is used to define the end of the group of operations within the loop.
The condition is evaluated BEFORE a run in the loop. That means it will evaluate if it should run the first time or not. Potentially resulting in
no processing of the loop depending on the condition.
Example
1 2 3 4 5 6 7 8 |
dcl-s i int inz(0); dow i < 10; i += 1; dsply 'This is loop number ' + %char(i); enddo; // For each loop, while i is less than 10, will the text "This is loop number nn" be shown on the screen where the nn is the number of the loop |
Example RPGIV Free Format
1 2 3 4 5 6 7 8 9 10 11 12 |
D i 3I 0 D Message 52A * C Z-Add *Zero i * C Dow i < 10 C Add 1 i C Eval Message = 'This is loop number ' + %char(i) C Message Dsply C EndDo * * For each loop, while i is less than 10, will the text "This is loop number nn" be shown on the screen where the nn is the number of the loop |