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


  • Subject: RE: %EOF - more on GOTO
  • From: "John Taylor" <john.taylor@xxxxxxxxxxxxxxx>
  • Date: Fri, 18 Jun 1999 16:38:50 -0600
  • Importance: Normal



> -----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          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


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.