Thanks all for the help.
I think I'll wait for Monday morning and see if it's any easier to understand. Too near quittin' time ater a long week here.
-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Kurt Anderson
Envoyé : vendredi 13 février 2009 15:58
À : RPG programming on the IBM i / System i
Objet : RE: Declaring the same DS in caller and callee
David,
Unfortunately I can't find IBM documentation to back this up, but normally the Based keyword has a pointer as its parameter (e.g. Based(pMyVar)). However, if you give it a bogus pointer, no memory will ever be allocated for that variable - hence it's "template" nature.
In Charles' example, he uses TEMPLATE as the bogus pointer. In all of my coding I've always seen Based(@) used for the TEMPLATE (likely originated with a code example from someone's article).
Also, I think you missed what Charles was saying about the definition. Put the prototype AND the data structure definition into a copybook and copy that into both the service program and the calling program. (Though I guess that's an assumption because you didn't say the caller was a separate program, could be just another procedure, in which case I'd define the DS in both procedures).
-Kurt
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of David FOXWELL
Sent: Friday, February 13, 2009 8:11 AM
To: RPG programming on the IBM i / System i
Subject: RE: Declaring the same DS in caller and callee
Sorry to be so dumb, but, I scanned the whole of the RPGILE reference manual for TEMPLATE and didn't find it.
I'm having trouble understanding what difference based(TEMPLATE) makes. Also, surely myrecord must be defined in both caller and callee?
Thanks.
-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Charles Wilt Envoyé : vendredi 13 février 2009 14:48 À : RPG programming on the IBM i / System i Objet : Re: Declaring the same DS in caller and callee
//Prototype source member QPROTOSRC/MyProc
d myParmDS ds based(TEMPLATE) LIKEREC ( myrecord : *INPUT )
d MyProcedure pr
d parm1 likeds(myParmDS)
Then in the callee and the caller, simply /copy QProtoSrc,MyProc
Charles
On Fri, Feb 13, 2009 at 8:24 AM, David FOXWELL <David.FOXWELL@xxxxxxxxx> wrote:
Thanks, could you explain that in more detail? I don't understand.
We are on V5R4.
-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Charles Wilt
Envoyé : vendredi 13 février 2009 13:18 À : RPG programming on the IBM
i / System i Objet : Re: Declaring the same DS in caller and callee
I usually declare such DS's as BASED( TEMPLATE) or with v6r1 use the new TEMPLATE keyword in the copy source member containing the prototype.
That way both the callee and the caller are using the same prototype and the DS definition.
HTH,
Charles
On Fri, Feb 13, 2009 at 3:04 AM, David FOXWELL <David.FOXWELL@xxxxxxxxx> wrote:
Hello all,
If I have this in an external procedure,
D myDS DS LIKEREC ( myrecord : *INPUT )
CHAIN mykey myfile myDS;
If I wanted to call the procedure and get the whole record or just parts of it, how should I declare the variables in the calling procedure so that they match those in the external procedure?
Thanks.
--
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.
--
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.
--
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.
--
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.
--
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.
--
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.