|
There are times when LEAVE and ITER are the best solution. I don't use them alot, but this instance it seemed appropriate. The Destination of a LEAVE in this type of situation in NOT implicit. By definition, it will exit the loop. It is not near as drastic as a GOTO. Sharon -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Dunfee, Randy Sent: Wednesday, February 28, 2007 3:20 PM To: RPG programming on the AS400 / iSeries Subject: RE: CHAIN Versus SETLL and READ When Data Needed I would prefer that the LEAVE opcode had never been added. IMHO, it is EVEN WORSE than a GOTO because the destination is implicit. I believe that when I see a conditioned DOU loop or a DOW loop that I have the right to expect that the ONLY way out of this loop is to meet the stated condition, and I can therefore skip desk-checking the "loop" code if that particular condition is not of interest to me. Is that REALLY too much to ask? Randy -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Sharon Wintermute Sent: Wednesday, February 28, 2007 4:07 PM To: RPG programming on the AS400 / iSeries Subject: RE: CHAIN Versus SETLL and READ When Data Needed Shannon, I have come to the point where i nearly HATE if with nested else groups. I have started going this route. DOU (wExit = Yes); SETLL all three if %Equal; Leave; Endif ; SETLL 2 keys if %Equal; Leave; Endif; setll 1 key Leave; Enddo; This way i always have the status If I need to know which file I add a flag. wExit is never set anywhere in the routine. Its only used as a way to loop. Sharon
The program logic is such that you check the maximum number of keys for a match down to the minimum number of keys Like this: Key1 Klist Kfld Fld1 Kfld Fld2 Kfld Fld3 Key2 Klist Kfld Fld1 Kfld Fld2 Key3 Klist Kfld Fld1 Which one of these logic blocks is most efficient? Key1 Setll file If %FOUND(file) Key1 READE file Use Fields Else Key2 Setll File If %FOUND(file) Key2 Use Fields Else Key3 Setll File If %FOUND(file) Key3 READE file Endif Endif Endif OR.... KEY1 Chain file If %FOUND(file) Use fields Else KEY2 Chain file If %FOUND(file) Use Fields Else KEY3 Chain file If %FOUND(file) Use Fields Endif Endif Endif My opinion is that the CHAIN is more efficient from both a coding/maintenance standpoint and from an I/O standpoint, but I'm open to opinions. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
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.