Repeat the same processing. But where does the repetition stop?
While writing RPG on IBM i, I wanted to check the behaviour of the DOU operation again.
DOU repeats a group of operations until its condition becomes true. What I wanted to confirm was when that condition was tested.
Run through the operations, then test the condition at ENDDO. If it is true, finish the loop and continue after ENDDO.
Was that the right understanding?
I asked Kimiko-chan—the name I gave ChatGPT.
I added a small comment to my question:
“Someone might say I should have asked this years ago. (Laughs.)”
After all my time writing RPG, here I was asking when a loop tested its condition.
But that was exactly what I wanted to check.
With DOU, the condition is written on the line at the start of the loop. That does not mean it is tested before entering the loop body.
In the normal flow, the body runs once first. The condition is tested afterwards. False means another iteration; true means leaving the loop.
Where the condition is written and when it is tested are separate questions. I wanted to trace the execution with that distinction clear.
There was another point to make explicit: did true mean “continue” or “finish”?
I wanted to be clear about that direction too.
Processing first. Test afterwards. Finish when true.
That was the sequence my question was really about.
Even after years of programming, putting my understanding into words makes it easier to see what needs checking.
Instead of stopping at “I know DOU,” I asked where the test happened and where execution went next.
I could laugh about asking so late and still be glad I had asked.
The operation was three letters long. What I wanted to check was the flow of execution beyond them.
Technical note
This article concerns free-form DOU in RPG. In normal execution, the loop body runs at least once and the condition is tested at the end. True takes execution past ENDDO; false starts another iteration. Early transfers of control, such as LEAVE or RETURN, are outside this explanation. The CL command is named DOUNTIL; its syntax is distinct from RPG’s DOU.
References, checked on 26 October 2026:
- IBM: DOU (Do Until), IBM i 7.6
- IBM: DOUxx (Do Until), IBM i 7.4 — the related operation referenced by the DOU documentation; includes the condition test at ENDDO.