| Replacing *ENTRY PLIST with a Prototype |
|
|
|
Q. I am trying to find the /Free replacement for the *ENTRY PLIST. The conversion tool in WDSc doesn't touch this code. Is it possible to do this in /Free code? A. You're probably comfortable coding a prototype and procedure interface for a subprocedure. But you can also use PR/PI definitions to replace the *ENTRY PLIST for an RPG IV program When coding a procedure interface for a main procedure (i.e., a program), you must remember a few additional requirements:
You have a choice when naming the prototype and the procedure interface. You can name the PR and PI descriptions to match the name of the module, or you can assign a name of your choosing -- perhaps a shop-standard name such as Main. If the name on the PR/PI descriptions doesn't match the module name, you must specify the module name with the Extpgm keyword (e.g., EXTPGM('MYPGM')). Here's a sample *ENTRY PLIST for a program named MYPGM and a pair of sample PR/PI combinations to replace it. *ENTRY PLIST: C *Entry Plist C Parm CpyNbr 5 0 C Parm AcctID 7 Corresponding PR/PI description: // ------------------------------------- Prototypes D Mypgm PR ExtPgm D 5 0 D 7 // ----------------------- Main procedure interface D Mypgm PI D CpyNbr 5 0 D AcctID 7 Or: // ------------------------------------- Prototypes
D Main PR ExtPgm('MYPGM')
D 5 0
D 7
// ----------------------- Main procedure interface
D Main PI
D CpyNbr 5 0
D AcctID 7
You can call this program (MYPGM) from any program, whether or not the calling program prototypes the call. The calling program can even be a CL program or an RPG III program. If the calling RPG IV program also has a prototype for MYPGM, the caller can use a free format call to MYPGM. For example: // ------------------------------------- Prototypes
D Mypgm PR ExtPgm('MYPGM')
D 5 0
D 7
/Free
Mypgm(Company:Customer);
/End-free
There are several reasons you might want to switch to using PR/PI descriptions instead of an *ENTRY PLIST. First, the coding is consistent with the coding required for subprocedures, which don't support *ENTRY PLIST. Second, the free-format replacement specification for C-specs doesn't support the PLIST or PARM operation; free-format coding renders the *ENTRY PLIST obsolete. Last, you can take advantage of prototyping to better control how parameters are passed by using prototyping keywords such as Const and Options(*NoPass). Note that you can pass parameters by reference (just as you did with the *ENTRY PLIST) or by read-only reference (Const). You cannot, however, pass parameters by Value to a main procedure, nor does a main procedure support a return value. |