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



I think I have the most problem around trying to keep I/O from happening
multiple times needlessly. For example, my program might print a part
label and a box label with similar information. To prevent me having to go
to the order file multiple times, I read the order part information at a
high level in the program, and I have to pass that through the sub
procedures until its time to actually print the two labels. I could make
the information global, but I try to avoid that where possible.

* For a simplied example:
ECL1=$GetOrder(Order#)
EIX1=$GetXREF(ECL1)
callp $PartLbl(ECL1 : EIX1)
populate label data
callp $PrtPartLbl(LblData)
callp $BoxLbl(ECL1 : EIX1)
populate label data
callp $PrtBoxLbl(LblData)


* is better than:
callp $PartLbl(Order#);
ECL1=$GetOrder(Order#)
EIX1=$GetXREF(ECL1)
populate label data
callp $PrtPartLbl(LblData)
callp $BoxLbl(Order #);
ECL1=$GetOrder(Order#)
EIX1=$GetXREF(ECL1)
populate label data
callp $PrtBoxLbl(LblData)





From: Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
To: RPG programming on the IBM i / System i
<rpg400-l@xxxxxxxxxxxx>,
Date: 07/24/2012 11:21 AM
Subject: Re: Sub procedures and growing parameter lists
Sent by: rpg400-l-bounces@xxxxxxxxxxxx



hi Darren,

It's hard to say whether you're doing it "wrong," since I have only a
high-level description of what you're doing.

In my experience, when a subprocedure has too many parameters, it
usually indicates that the procedure is trying to do too many things.
IMHO, a subprocedure should just do one thing -- and when the time comes
to do the next thing, a separate procedure should be used. However,
it's very difficult (for me, at any rate) to describe what constitutes
"one thing."

And, there are certainly cases where a lot of data is required for just
one thing.

Nesting data structures inside other data structures is a relatively
simple solution -- but I find that when I do that, I have to work hard
to keep the DS names short -- otherwise, it becomes very difficult to
deal with the nested DS, the names quickly become too long.


On 7/24/2012 9:40 AM, darren@xxxxxxxxx wrote:

I have been using sub procedures exclusively in my code for about 3 years
now. One things that I continually have trouble with is a growing number
of parameters that I pass around. If one procedure gathers a bunch of
data
and a couple different sub procedures need to process with that data, all
of that data has to be declared and passed. I'm talking about data
structure data, so lumping the variables into a data structure would mean
data structures within data structures. I've done this data structure
nesting before and it looks confusing when I come back to it later. What
I
find myself wishing for is variables global to the current call level.
This could be accomplished with local subroutines I'd guess.

Am I doing it wrong?




--
This is the RPG programming on the IBM i / System i (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 thread ...

Follow-Ups:
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 copyright@midrange.com.

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.