On 23/05/2006, at 10:45 PM, rob@xxxxxxxxx wrote:

The basic gist of it is that subroutines have to be before the ENDPGM.

Sort of makes sense. ENDPGM marks the end of the source. Note that PGM and ENDPGM are not required by the OPM compiler. It flags their absence as a warning but will compile. You can even compile an empty source member using the CL compiler. No that's a NOP program! I presume the ILE compiler does the same.

If you screw up and put them after ENDPGM then the compiler ignores them. I haven't tested it but I bet you could type the 23rd Psalm after ENDPGM in
an otherwise valid CL program and it would be ignored.

Hmm, I wonder ...

pgm
endpgm
Yea, though I walk through the valley of the shadow of death,
I shall fear no evil:
For I am the meanest son-of-a-bitch in the valley!        

What do you know? It compiles. Interestingly the compiler output shows the source as:

                                      Control Language Source
SEQNBR *...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+
    100- pgm
    200- endpgm
* CPD0729 10  No executable commands found in source file.
* * * * * E N D O F S O U R C E * * * * *

That's only part of the problem. The other part is that instead of simply
flagging it as missing the subroutine the compiler goes off into La-La
land.  IBM has now recognized this and will fix it.

That's good to know.

I guess the testing involved only correctly written programs.  And not
programs written by someone who simply went to GO CMDSUBR as their sole
source for learning about subroutines in CL.
I've learned to use a simple RETURN before my subroutines to give me a
warm fuzzy about the end of the mainline before the start of the
subroutines.

I tend to always put a RETURN after the body of my CL. My generic error handler goes after the RETURN and before the ENDPGM.

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