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



Seems to me subroutines have a role.  Because RPG has so many global
variables, there are times when a procedure that uses globals requires
the original programmer and anyone who modifies the code to pretend
their values can't be changed by adding a line of code to the procedure
that assigns a value directly. Passing by value can't defend against
this. There are some ways around this by using a service program or a
program call so the global is out of scope, but in a lot of cases it's
not worth the trouble.

Another feature of RPG that makes subroutines attractive is that file
names and record format names can't be represented by string variables
so truly generic file routines are impossible. 

A third thing is that RPG data types except the integer, float, and
variable length character types have specific lengths.  (I know, int and
float types have length ranges.)  It's much easier to write a procedure
with arguments and return values that are more flexible than things like
packed 5,2 or char 8.  There are work arounds, but packed or signed
decimals work a lot better with money than anything else available.

Another factor, probably the root of it all, is that RPGIV has to be
backward compatible with the RPG Classic static memory model. 

For small to medium programs I use subroutines for things that happen
only once like beginning of program housekeeping stuff or things that
modify a lot of global variables at once like a file write. I try to use
procedures for everything else. 

I'm not saying you can't write a program that does everything with
procedures.  I believe that subroutines are sometimes a better tool for
the job.  They do provide functional decomposition and can be a
tremendous aid in making a program extensible if they're well designed
in the first place.  The don't hide data, but there's a lot of data
that's very hard to hide.

> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx
> [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan Campin
> Sent: Thursday, June 23, 2005 4:45 PM
> To: rpg400-l@xxxxxxxxxxxx
> Subject: RE: Assembly programmers do it a byte at a time
>

>>>>>>>>>>>>>>>>>>>>>  Big Snip <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
> As far as subroutines being at some level of modularization,
> I see what you are saying but I am uncomfortable with the
> idea that subroutines are part of modularization. I still
> have to use them with embedded SQL rather than doing /Free
> and /End-Free all over the place but other than that,
> subroutines should be dead, dead, dead. They provide nothing
> that you really need to write good code. When we had nothing
> else in RPG III, that was what you had but did not let you do
> much of anything in software engineering. Makes me shudder to
> remember the days of trying to write good code in
> subroutines. Like living a long running nightmare.   
> --
> 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.
>
>

*****************************
NOTICE:
All e-mail sent to or from this e-mail address will be received or otherwise 
recorded by
The Sharper Image corporate e-mail system and is subject to archival, 
monitoring,
and review by and/or disclosure to Sharper Image security and other management.
This message is intended only for the use of the addressee and may contain 
information
that is privileged and confidential.

The contents of this message may contain personal views which are not the views 
of The Sharper Image.
If you are not the intended recipient, dissemination of this communication is 
prohibited.
*****************************


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.