× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Two different but functionally equivalent “read equal” loops follow.

From many of the answers to other posts read thru this list, Style#1 seems to be the “preferred” one for most people.
But, IN MY OPINION, the second one should be more “appropiate” from RPG way of thinking...


C and PASCAL have a “before_read EOF detection”, whereas RPG and COBOL have a “after_read EOF detection”, thus :

- C/PASCAL loops were usually coded as
while NOT EOF(file)
do
read file
... process ...
enddo

- whereas RPG/COBOL loops used to be coded as , the
do “forever”
read file
at EOF(file) leave
... process ...
enddo

So, applying the C/PASCAL approach to RPG forces to include one additional “read” before the loop as in Style#1.

Just for curiosity, some people will code it the #2 way, but WHY do MOST people seem to prefer #1 ?

----- Style #1 -------------------------------------------
mykey setll record
if %equal
mykey reade record
dow not %eof
... process ...
mykey reade record
enddo
endif

----- Style #2 -------------------------------------------

mykey setll record
if %equal
do *HIVAL
mykey reade record
if %eof leave
... process ...
enddo
endif

--
Antonio Fernandez-Vicenti
afvaiv@xxxxxxxxxx



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.