× 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.




On 17/03/2006, at 4:06 PM, Mike Pantzopoulos - (H/O) wrote:

A little while ago I had cause to use the CALLPRC command in a CL
program. Simon Coulter (bless his little white socks), pointed me in the
right direction with regards to a variable length parameter set up from
the CL to the ILE procedure interface. Now I have a CL module and I am
able to create a program out of it(CRTPGM) or CRTBNDCL directly from the
module source.
I'm now curious about the differences between RPG & CL modules.

At the module level their aren't any real differences

An RPG module may have one or more procedures, but the CL module doesn't
seem to fit the RPG procedure template - no prototype, no internal
procedure declarations.

Support for multiple procedures is a compiler thing. RPG IV originally supported only 1 procedure per module--which is why we have the current rubbish about sub-procedures. At VRM370 RPG was given support for multiple procedures.

So the question is - what can I do with a CL
module other than create a module? I have to create a module because of
the reference to CALLPRC, but is there any other intrinsic reason for
using CL as a module?

I can think of four reasons why you might create a CL module (i.e., use CLLE) rather than stick with CLP: 1) You want to embed a copyright statement in the object via the COPYRIGHT command
        2) You want to call another procedure from CL via the CALLPRC command
3) You want to bind a CL module directly to your RPG/COBOL/C program rather than call a program
                - You might do this to:
                        a) reduce the number of shipped objects (1 program vs. 
2 or more)
b) reduce the possibility of interposing a different program on a call 4) You might want to bind multiple CLLE modules into a single program object

I thought I might be able to reference it from a CALLPRC in another CL,
but since there's no 'procedure' construct, what else can I do with it?

That's exactly what you can do. Specify multiple CLLE modules on the CRTPGM or CRTSRVPGM command and use CALLPRC to jump between them. CALLPRC is more like RPG's CALLB than CALLP. For the second time today: CALLP means Call with Prototype not Call Procedure. For example:

Source member CLMODULE1:
pgm
sndpgmmsg  'In module 1'
callprc clmodule2
endpgm

Source member CLMODULE2:
pgm
sndpgmmsg  'In module 2'
endpgm

CRTCLMOD CLMODULE1
CRTCLMOD CLMODULE2
CRTPGM CLMODULE MODULE(CLMODULE1 CLMODULE2)
CALL CLMODULE

The job log will contain "In module 1" followed by "In module 2' so you know that CALLPRC passed control as expected.

While I'm at it:

If the entire module is copied into a referencing module/program/service
program, then there seems to be a propensity to possibly create very
large programs by the time an executable is created as the tip of a
possibly very large pyramid of module references.

Only if the modules that are bound by copy are used in multiple programs. There is no real difference in object size between 1 program with 1 module of 50,000 lines and 1 program with 5 modules of 10,000 lines each.

Certainly the additional binding information in the program object and the module information overhead will increase the size of the resulting object but not significantly--especially not when weighed against the convenience of smaller source members, separated logic, etc.

It almost seems as if the best solution is to use a service program in
almost all instances, regardless of the slight overhead of the initial
reference.

But the modules are copied into the service program ....

If the module in question is common to 2 or more programs or service programs then it should itself be bound into a common service program. If the module is only used by one program then just bind it into that program.

The number of modules per program should not be a consideration. What matters is whether the modules effectively separate logic or function such that maintenance is improved. If that means 50 modules in a given program then so be it.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------


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.