|
It may be a matter of taste, but I think this is a situation that SELECT would handle simply and elegantly. -----Original Message----- From: John Taylor [mailto:john.taylor@telusplanet.net] Sent: Friday, June 18, 1999 3:39 PM To: RPG400-L@midrange.com Subject: RE: %EOF - more on GOTO > -----Original Message----- > From: owner-rpg400-l@midrange.com [mailto:owner-rpg400-l@midrange.com]On > Behalf Of bellis@ORIENTAL.COM > Sent: Friday, June 18, 1999 3:01 PM > To: RPG400-L@midrange.com > Subject: RE: %EOF > <snipped> > By the way, you should never have to use a GOTO in an RPG program !!! No, you never really HAVE to. However, when used responsibly, a GOTO can be quite usefull. Take for example a standard error checking subroutine such as the following: SR ChkForErr BegSR * Initialize routine C Eval ErrorID = *Blanks * Do some testing & branch to error section when required C If ( SomeCondition <> Valid ) C Eval ErrorID = "SomeErrorID" C Goto ErrSection C Endif C If ( SomeOtherCondition <> Valid ) C Eval ErrorID = "SomeOtherErrorID" C Goto ErrSection C Endif * Add a whole bunch of other tests here * Error Section C ErrSection Tag C If ( ErrorID <> *Blanks ) C Eval DspErrInd = *On * <add additional common error handling code here) C Endif SR EndSR Sure, you could code this without using a GOTO, but it would mean adding more code that is just not necessary. The routine only exits at one point, and the logic does not jump around from place to place. The bottom line, for me, is that the GOTO is not evil. The programmer who uses it irresponsibly is. And a programmer who abuses the GOTO statement is also likely to abuse any other op-code that he's learned. How many times have you seen code that moves *BLANKS into a decimal field? John Taylor * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This is the RPG/400 Discussion Mailing List! To submit a new * * message, send your mail to "RPG400-L@midrange.com". To unsubscribe * * from this list send email to MAJORDOMO@midrange.com and specify * * 'unsubscribe RPG400-L' in the body of your message. Questions should * * be directed to the list owner / operator: david@midrange.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This is the RPG/400 Discussion Mailing List! To submit a new * * message, send your mail to "RPG400-L@midrange.com". To unsubscribe * * from this list send email to MAJORDOMO@midrange.com and specify * * 'unsubscribe RPG400-L' in the body of your message. Questions should * * be directed to the list owner / operator: david@midrange.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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.