× 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 either developed this method or picked it up from somewhere, but you can
avoid the separate /copy member, and still have the prototype only defined
once with compiler directives. This example is in the callee. For the
caller, you simply /define(PrototypesOnly) and then /copy the source for
the caller into your program. I also did a sort of recursive compiler
directive where I only had to define the parameters once, but it can look a
little confusing, so I mainly use this method.


/if not defined(PrototypesOnly)
H ActGrp(*NEW) DftActGrp(*NO) ExprOpts(*RESDECPOS) DatFmt(*USA)
H option(*SRCSTMT:*NODEBUGIO:NOUNREF) EXTBININT(*YES)
/endif
//--------------------------------------
// Prototype for procedure *ENTRY parameters
//--------------------------------------
D GDSMBOM1 PR extpgm('GDSMBOM1')
D INPPart 15 const
D INFac 2 const

/if defined(PrototypesOnly)
/eof
/endif

*ENTRY parms
D GDSMBOM1 PI
D INPPart 15 const
D INFac 2 const



From: Barbara Morris <bmorris@xxxxxxxxxx>
To: rpg400-l@xxxxxxxxxxxx
Date: 06/26/2013 05:14 PM
Subject: Re: Converting *ENTRY & PLIST to free format
Sent by: rpg400-l-bounces@xxxxxxxxxxxx



On 6/26/2013 6:45 AM, Brian Parkins wrote:
...
The following example works perfectly well - now that we can specify
EXTPGM
on the PI in Program B. Yet the code appears to contradict the Manual.
========================================
// Module/program name is PROGRAMA
D CallParms Pr ExtPgm('PROGRAMB')
...
========================================
// Module/program name is PROGRAMB
// No Prototype (PR)
D EntryPlist Pi ExtPgm('PROGRAMB')
...
========================================
...
I agree wholeheartedly that using /COPY to embed the PR in both programs
is desirable for building more robust code. (I do come across
installations where standards expressly forbid the use of /COPY - hence
another appeal of the V7.1 enhancements.)

Brian, you're right that it's possible to code that way. The manual
isn't talking about rules that can be enforced, it's talking about rules
that should be followed.

I don't think it's a good idea to make it easier for new prototype-ers
to just put the PR in the caller and omit the PR in the callee.

You already need two source members for the lesson anyway. Adding a
third one with the copy file is not that big a deal.

I think we should start right off with the one-and-only prototype in the
copy file, and explain to the students that the prototype's main purpose
is to ensure that the procedure and its caller both have the same idea
about the return type and parameters, and that the only way to ensure
this is for them to use the exact same prototype in the exact same
source member.

If you only focus on the caller side of the prototype, you have to teach
a more complex and frustrating lesson later about why they really should
put the prototype in a copy file and copy it in.

Analogy: Teaching someone to drive a car, and teaching them about
seatbelts on the second lesson.

--
Barbara
--
This is the RPG programming on the IBM i (AS/400 and 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.




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.