Moving to prototypes and /FREE (correcting my last post)

90 pts.
I want to change the following to using prototypes and /FREE... how do I do that?

D RDCTL         E DS                  EXTNAME(RDCTL) 

C     *ENTRY        PLIST                          C                   PARM                    RDCTL  C                   PARM                    PDEDS 

C                   CALL      'RDRE1RPG'          C                   PARM                    RDCTL

I've tried to figure it out, but the use of a data structure is throwing me a curve.  Thanks for your help

Software/Hardware used:
iSeries V5R4

Answer Wiki

Thanks. We'll let you know when a new response is added.

I can supply an extremely limited version of what you have. It’s not something that I’d ever be likely to create and I sure can’t test it. But you can look it over and follow up with whatever questions might arise. I left everything in that you had, converted to comments:
* Give this DS a different name — avoid conflicts…
* Changed DS name from RDCTL to RDCtlDS. My EXTNAME() is ACCPTH because
* I didn’t have anything named RDCTL. Originally, the DS had the same
* name as the EXTNAME()…
D RDCtlDS e ds extname( ACCPTH )

* Set a prototype for calling RDRE1RPG, an external program…
* Note that normally a prototype parm doesn’t need a name. However, a
* pDS is given here in order to let the compiler know that the LIKEDS()
* keyword is associated with a parm, rather than being a keyword that
* is associated with the EXTPGM() above…
D OtherRPGIV pr extpgm( ‘RDRE1RPG’ )
D pDS likeds( RDCtlDS )

* Set a prototype for calling this.Program…
D MyRPGIV pr extpgm( ‘MYRPGIV’ )
D CtlDS likeds( RDCtlDS )
D EDS 10
* Set a procedure interface — there is only one proc here…
D CtlDS likeds( RDCtlDS )
D EDS 10


// We handle the *ENTRY by declaring prototype/interface…

// We can use CALLP with a prototyped program…
callp OtherRPGIV ( RDCtlDS ) ;

// We handle the CALL with CALLP…

*inlr = *on ;

If you remove all the comments, it’ll be easier to see what remains. There are more source specs, but a number of additional features become available along with them.

As for the DS, LIKEDS() allows you to define parms to inherit structures. The parms will match with the structure of the defining DS. Hardly any problem at all.

One quirk appears in some cases because prototypes (PR) technically don’t need names for parms, generally only data type and size attributes. In the case of a LIKEDS() parm, type and size specifications aren’t needed since they’re implicit in the DS itself. If you don’t supply a “name” to act as a kind of placeholder, the compiler mistakenly believes that the LIKEDS() keyword is a continuation of keywords from the line above. The name is unimportant on the prototype, although it is significant and must be specified on any interface (PI) that is based on the prototype.


Discuss This Question: 2  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Teandy
    Try this: [code] ********************************************************************** * ENTRY PARMS. ********************************************************************** D ENTRYPARMS PR ExtPgm('MYPGM') D RDCTL 10 D PDEDS 10 D ENTRYPARMS PI D RDCTL 10 D PDEDS 10 CALLP RDRE1RPG( RDCTL); [/code]
    5,860 pointsBadges:
  • BigKat
    I like to add a comment line before my PR and PI for the main program (i.e. the program you are currently writing) that says * *ENTRY prototype since one of the first things I do when analyzing an existing application (since most have been around awhile) is to do a find on *ENTRY to see what the parameters are. It also helps some of the others working here wh ahve been around a while too :)
    9,460 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: