I like style 1 because that's how I learned to do loops...by first
creating a Warnier-Orr diagram and then putting it to code. The other
reason I like it is that I don't use a (essentially) a goto. I believe
the compiler actually will implement style 2 even if you code the high
level language using style 1.

On Fri, 21 Nov 2003 05:58:13 +0100, "afvaiv" <afvaiv@xxxxxxxxxx> said:
> 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
> 
> 
> _______________________________________________
> This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
> list
> To post a message email: MIDRANGE-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/midrange-l
> or email: MIDRANGE-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/midrange-l.
> 
-- 
  
  michaelr_41@xxxxxxxxxxxxxx

-- 
http://www.fastmail.fm - IMAP accessible web-mail


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.