Thank you, Jean-Marc. I quite agree with you that this alternative coding would work. But for the record, this is no longer a Linear Main *MODULE as per my original query. (By omitting the CTL-OPT keyword - MAIN(MAINPROC) - it has become a Cycle Main *MODULE.)

Thank to Barbara and Jon for sorting out my fuddled brain.

Brian.

On 15/05/2024 09:50, Jean-Marc DUVAL via RPG400-L wrote:
Hi,

I would write it like this :

// Linear Main *MODULE with subprocedure
**free
ctl-opt dftactgrp(*no);
dcl-pr mainproc extpgm('PGM2_PROC1') end-pr;
dcl-pi mainproc end-pi;
dcl-s userid char(10) inz(*user);
dsply 'in mainproc' userid;
msg();
return;
dcl-proc msg;
dcl-pi msg;
end-pi;
dcl-s userid char(10) inz(*user);
dsply 'in msg proc' userid;
return;
end-proc;

-----Message d'origine-----
De : RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> De la part de Brian Parkins
Envoyé : mercredi 15 mai 2024 10:24
À : RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxxxxxxxx>
Objet : EXPORTing subprocedures



ATTENTION : Ce message provient d'une source EXTERNE. Veuillez n'ouvrir les liens ou pièces jointes que si vous êtes sûr de l'expéditeur.



OK, here is something I have never quite understood. Can anyone explain why subprocedures within a Linear Main *MODULE have to be EXPORTed - even when only referenced within the same *MODULE?

Example: A single source member follows, (please be gentle with my
coding.) CRTBNDRPG used with this particular example.
**Free
// Linear Main *MODULE with subprocedure // Subprocedure MSG requires EXPORT keyword - why???
Ctl-Opt DftActGrp(*No) Main(MainProc);
Dcl-PR MainProc ExtPgm('PGM2_PROC1');
End-PR;
Dcl-Proc MainProc;
Dcl-PI MainProc;
End-PI;
Dcl-PR Msg;
End-PR;
Dcl-S UserId Char(10) Inz(*USER);
Dsply 'In MainProc' UserId;
Msg();
Return;
End-Proc;

Dcl-Proc Msg Export;
Dcl-PI Msg;
End-PI;
Dcl-S UserId Char(10) Inz(*USER);
Dsply 'In Msg Proc' UserId;
Return;
End-Proc;

If I rewrite the above as a Cycle Main *MODULE, the EXPORT keyword is not required on the subprocedure. The RPG Reference states:
"If the EXPORT keyword is not specified, the procedure can only be called from within the module."
So why is EXPORT needed in the above example? (If it is removed, a bind error occurs.)

Thx for any insight.
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://urldefense.com/v3/__https://lists.midrange.com/mailman/listinfo/rpg400-l__;!!J76aczzK!zo8Dezhv3kneNFEXPO2Hl9M6M4ZUhQdBsb93jeEJcbdbeWR72nV8t7b3XdNJUKuW4xfguW80lRnU1UEW9bi8yXYROwO39wQ$
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://urldefense.com/v3/__https://archive.midrange.com/rpg400-l__;!!J76aczzK!zo8Dezhv3kneNFEXPO2Hl9M6M4ZUhQdBsb93jeEJcbdbeWR72nV8t7b3XdNJUKuW4xfguW80lRnU1UEW9bi8yXYRnyNmJWo$ .

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.



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.