In my copy source member I break things out into sections, such as:
//=======================================================================*
// Shared Prototypes *
//-----------------------------------------------------------------------*
And...
Shared Templates
Shared Constants
Shared Variables (here I do note that the value isn't shared)
So in your case David, the MyArray definition wouldn't be "lost" mixed in with the prototypes, it'd be designated under Shared Templates section. However that's just my personal preference.
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Christen, Duane
Sent: Thursday, January 28, 2010 8:34 AM
To: RPG programming on the IBM i / System i
Subject: RE: Array DS as return variable
David,
I would add a recommendation to what Joep said.
1. Change the name MyArray to MyArray_t or MyArrayTemplate (or something similar) this allows the next programmer that maintains this code to know at a glace that this is a template.
Duane Christen
--
Duane Christen
Senior Software Engineer
(319) 790-7162
Duane.Christen@xxxxxxxxxx
Visit PAETEC.COM
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of J.Beckeringh@xxxxxxxxxxxxxxxxxxxxxxxxxx
Sent: Thursday, January 28, 2010 6:39 AM
To: RPG programming on the IBM i / System i
Subject: Re: Array DS as return variable
David,
The MyArray-defintion is not a declaration of a variable (well, strictly speaking you are defining pointer variable TEMPLATE); no storage is allocated for MyArray. With wArray you define a variable. To me a template data structure is a lot like a prototype; you might think of it as a prototype for a data structure. Whenever I use complex parameters in prototypes I include the templates in the same include member.
Joep Beckeringh
David FOXWELL
Hi,
I've coded my first array DS as a return variable as below. I'm
wondering if I've made a meal of it. I've added a definition of the
array immediately after the prototype so that callers will have this
definition. However I don't much like mixing the declaration of
variables and prototype.
Any suggestions?
D MyProc PR LIKE ( MyArray )
D DIM ( %ELEM ( MyArray ))
D MyArray S LIKE ( MyDefinition ) DIM ( 10 )
D BASED ( TEMPLATE )
P MyProc B
D PI LIKE ( MyArray )
D DIM ( %ELEM ( MyArray ))
D wArray S LIKE ( MyArray )
D DIM ( %ELEM ( MyArray ))
/FREE
RETURN wArray;
/END-FREE
--
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.