<b>dow tests the condition at the start of the loop – at the dow statement.
dou tests the condition at the enddo statement.</b>
DOW — Do While — does the statements in the DO-group <i>while</i> the condition is true. The logical test for the condition happens at the DOW statement, i.e., at the beginning. This implies that the statements won’t be executed at all if the condition is false at the time the DOW statement is executed.
DOU — Do Until — does the statements in the DO-group <i>until</i> the condition is true. The logical test for the condition happens at the ENDDO statement. This implies that the statements will always be executed at least once when the DO-group is reached.<pre>READ MyFile
DOW NOT %eof(MyFile)
Using a DOW for a READ-loop requires a “priming” READ outside of the loop in case the %EOF() condition is true on the first READ. Note that the condition uses a “NOT” operator.<pre>DOU %eof(MyFile)
IF NOT %eof(MyFile)
ENDDO</pre>A DOU READ loop does not require a “priming” READ, but then an IF-statement needs to be inside the loop to separate what happens when %EOF() happens from when it doesn’t.