|
I agree. While I used to follow the "only-one return" practice, I've since moved to the idea of "don't surprise me with a return". So my procedure will either have one return or like your example, lots of returns. I find the multiple returns easier to read than deeply nested IFs; especially given RPGLE limitation of 80 columns. Using return makes it clear that "if whatever", this procedure is done...no ifs and or ELSE. Charles Wilt -- iSeries Systems Administrator / Developer Mitsubishi Electric Automotive America ph: 513-573-4343 fax: 513-398-1121 > -----Original Message----- > From: rpg400-l-bounces@xxxxxxxxxxxx > [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Lim Hock-Chai > Sent: Thursday, July 28, 2005 9:53 AM > To: RPG programming on the AS400 / iSeries > Subject: RE: No Subroutines (was Re: Debugging many subprocedures) > > > I've always struggle with the concept that: using return > opcode to exit subprocedure in the mid of subprocedure is bad thing. > > I do not see a problem of coding something like this: > > p mySubProd B > D pi > D record likeDS(recordDS) > > * only process certain type of record > C if record.type <> "xxx" > C return > C endif > > * only process if user is auth to this record > C if not isAuth(record) > C return > C endif > > * other checking before process > C . . . . > > > * process it > C . . . . > > p mySubProd E > > > Of course, return is like goto, it can be misuse easily. > > > ----Original Message----- > From: rpg400-l-bounces@xxxxxxxxxxxx > [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Joe Pluta > Sent: Wednesday, July 27, 2005 9:11 PM > > <clip> > And procedures can be misused most horribly. One of the > worst offenses > I see is procedure with a bunch of return opcodes strewn > throughout it. > At least with a subroutine you can stick a breakpoint on the ENDSR and > know it will get there. > </clip> > > -- > 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.