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



The minute I learned about prototyping programs, I started doing it for
its compactness. Speaking more generally, when I encounter monolithic RPG
programs where changes need to be made, I will often rewrite them when it
makes sense to do so. I find they can be such a pain to decipher. (WDSc
and RDP are very helpful in such scenarios incidentally.) It's not RPG
III/400 so much as the way the code was written, but using modular
programming techniques and /free format, I've cut the LOC by nearly half
in some instances. The result is the same, but with more readable and easy
to maintain code IMO. Granted some of that is removing superfluous
variables and repeated code blocks, but Barbara's example below
demonstrates how newer language features can be more efficient. Of course,
one could argue that using the logic cycle is more efficient, though
arguably more obscure. Recently I had to refresh myself on the cycle and
learn about using program described files with matching fields. It was
interesting to learn how old school RPG works, but I'm thankful that IBM
provides good documentation.

As I'm finishing this, someone came to me with a problem with one of those
old school programs. Guess I shoulda kept my mouth shut...

Blake



date: Wed, 29 Jun 2011 19:26:32 -0400
from: Barbara Morris <bmorris@xxxxxxxxxx>
subject: Re: Impossible to even think about rewriting in RPG

On 6/29/2011 6:22 PM, John Yeung wrote:

... my excuses for
avoiding use of prototypes. ...


You don't have to get into modules and service programs to get the
benefits of prototypes. You can use prototypes for program calls too.

You do need to put the prototypes into a /copy file, but once you get
that set up to have the prototypes copied into the programs and their
callers, the cost of doing that extra work to create the prototype for a
new program is minor compared to the benefits you get from using
prototypes.

Using prototyped calls has little or nothing to do with modularity, and
everything to do making it easier to call your programs, and letting the
compiler help you get the parameters right.

Compare

D parm1 s type for parm 1
D parm2 s type for parm 2

c eval parm1 = value for parm1
c eval parm2 = value for parm2
c call somepgm
c parm parm1
c parm parm2

to

c callp somepgm (value for parm 1
: value for parm 2)

You only need to define variables for your parameters if the program
will modify the parameter. So you save both D specs and C specs when you
use a prototyped call.

Instead of *ENTRY PLIST, you /copy the prototype and define the PI in
the called program, and the compiler can help you get your parameters
matched between the program and its callers.


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.