** This thread discusses the article: My Way of Looping **
I think my favorite way of looping solves the problem of wether to put a read inside or outside the loop. I'm coding the read at the loop's "border" as part of the DOW condition. Please see example below, MYFILE is read in the procedure getNextRecord, I like the cleanness of this technique.
Code:
FMYFILE IF E K DISK
D getNextRecord PR N
/free
Setll (firstKey:secondKey) MyFile;
DoW getNextRecord();
If (field=condition ); // Check if wanted record
... ; // Process record
Endif ;
EndDo;
*inlr=*on;
/end-free
//---------------------------------------------------------------
// Read Next Record
//---------------------------------------------------------------
P getNextRecord B
D PI N
/free
// Read data
Read MyRecord;
Return Not %EOF;
/end-free
P E