My Way of Looping
** This thread discusses the article: My Way of Looping **
I can't imagine why people prime the pump and then issue another read at the bottom of the loop. I've done "My Way" since 1998. I had a heck of a time convincing people that it basically saved a read by doing it that way. I don't use the DOW though. I use DOU. Don't know why either won't be as effective as the other.
orderKey setll S1ORDHSTD2
DoU %eof(S1ORDHSTD2)
orderKey readE S1ORDHSTD2
If %eof(S1ORDHSTD2)
Leave
EndIf
f the line is not marked as 0 in then Iter.
If S1HSTSEL <> *zero
Iter
EndIf
Enddo
Unconfigured Ad Widget
Collapse
Announcement
Collapse
No announcement yet.
My Way of Looping
Collapse
X
-
** This thread discusses the article: My Way of Looping **
I have used your "new" method for 5250 display files for years. I never really saw the need to do it with DB tables.
Leave a comment:
-
My Way of Looping
** 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.Tags: None
Leave a comment: