×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




This is my take on what the program should look like.

It seems like you should have a prototype declared for the Main Procedure
to declare the program name and
that you should have dcl-pi and end-pi after the dcl-proc. Not sure why
it would compile without them.

**Free
Ctl-Opt DftActGrp(*No) ActGrp(*New) Main(Proc1);

dcl-pr Proc1 ExtPgm('Pgm1') end-pr;

dcl-proc Proc1;
dcl-pi *N end-pi;

Dsply 'In main Proc' *REQUESTER;
Proc2();
Return;
end-proc;

dcl-proc Proc2;
dcl-pi *N end-pi;

Dsply 'In Proc2' '*REQUESTER';
Return;
end-proc;

On Thu, Nov 12, 2020 at 10:18 AM Brian Parkins <goodprophet.bp@xxxxxxxxx>
wrote:

Here's a puzzle. Does anyone have a good explanation? I have a source
member containing two procedures - the main (entry) procedure and a
subprocedure (PROC2). The main procedure calls the subprocedure.

If I code this as a Cycle Main program, all works well. Example:

**Free
Ctl-Opt DftActGrp(*No) ActGrp(*New);
// Main Entry procedure
Dcl-PR Proc2;
End-PR;
Dsply 'In main Proc' '*REQUESTER';
Proc2();
*InLR = *On;
Return;
Dcl-Proc Proc2;
// Internal subprocedure
Dsply 'In Proc2' '*REQUESTER';
End-Proc;

If I code this as a Linear Main program, PROC2 requires the EXPORT
keyword, e.g.

**Free
Ctl-Opt DftActGrp(*No) ActGrp(*New) Main(Proc1);
Dcl-Proc Proc1;
// Main Entry procedure
Dcl-PR Proc2;
End-PR;
Dsply 'In main Proc' '*REQUESTER';
Proc2();
Return;
End-Proc;
Dcl-Proc Proc2 Export;
// Internal subprocedure
Dsply 'In Proc2' '*REQUESTER';
End-Proc;

(The source will compile but the Bind step fails without the EXPORT
keyword - "No definition was found for reference PROC2 in *MODULE".)
Why is the EXPORT keyword required? (I've not been able to find any
clear explanation in the manual - tell me what I'm missing.)

FOOTNOTE: If I modified the coding of the second example and EXPORTed
PROC1, I could then create a *SRVPGM which did /not/ require PROC2 to be
EXPORTED. Odd!

Brian.
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


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