** This thread discusses the article: My Way of Looping **
** This thread discusses the Content article: My Way of Looping **
I'm afraid I belong to the other school of thought where a priming read
is done BEFORE the DOW loop and read the next record before the enddo.
It stems from the good old days of indicators; eg DOW not *in99
If whichever indicator you were using to control the loop had been set on elsewhere in the program and not initialised before the loop? - oops!!
The opening SETLL does not set the indicator or the %EOF.
Also, the checks for EOF and record not wanted result in an ITER statement
ie; a glorified GOTO.
Why not just check if this is a required record?
setll keylist myfile;
reade keylist myfile;
dow not %eof(myfile);
If check = whatIwant;
-- process this record;
endif;
reade keylist myfile;
enddo;
The only time I would use the read inside the loop (at the top of the loop)
would be when using a DOU to make sure at least one attempt to read the file
was done and the indicator or %eof set accordingly but then that needs
another IF statement inside the loop to check %eof.
** This thread discusses the Content article: My Way of Looping **
I'm afraid I belong to the other school of thought where a priming read
is done BEFORE the DOW loop and read the next record before the enddo.
It stems from the good old days of indicators; eg DOW not *in99
If whichever indicator you were using to control the loop had been set on elsewhere in the program and not initialised before the loop? - oops!!
The opening SETLL does not set the indicator or the %EOF.
Also, the checks for EOF and record not wanted result in an ITER statement
ie; a glorified GOTO.
Why not just check if this is a required record?
setll keylist myfile;
reade keylist myfile;
dow not %eof(myfile);
If check = whatIwant;
-- process this record;
endif;
reade keylist myfile;
enddo;
The only time I would use the read inside the loop (at the top of the loop)
would be when using a DOU to make sure at least one attempt to read the file
was done and the indicator or %eof set accordingly but then that needs
another IF statement inside the loop to check %eof.
Comment