× 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.



I generally use method one out of habit. The "leave" opcode is
"relatively" recent in rpg. Also, I have seen in the past argument that
suggest that the leave opcode is just a goto in disguise and thus should
be avoided (but I do not agree with that point of view).

Since people bring into this discussion C and Pascal, I would like to
mention that, in my opinion, the Lisp language had the best idea as to
how to manage loop. I wont post lisp code ((((way too many
parenteses)))).

The idea was to separate the loop bondary from the loop condition. Here
is some pseudo code to explaine:

- loop-begin-tag
- some instructions
- loop-condition
- some instructions
- loop-end-tag

the "some instructions" part can have 0,1 or more instructions. Thus,
with one construct, you support DOW and DOU and all computation related
to the loop condition (like a read) can be group together.

I dont know why but I seem top be the only one who like this.

My 2 canadian cents. (about 1.5 real cent)

Denis Robitaille
Directeur services technique TI
819 363 5187

SUPPORT
Jour (EST) Daytime : 819-363-5087
En-dehors des heures (EST) After hour : 819-363-5095
Network Status : 819-363-5096

>>> afvaiv@xxxxxxxxxx 2003-11-20 23:58:13 >>>
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.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.