|
Jake,
I - Calling from a different program.
What is often done is cutting out the
D PROTO_02 PR EXTPGM('PROTO_02')
D num1 15P 5
D num2 15P 5
and putting that into a seperate source member. Like QPROTOSRC,PROTO_02.
And in the PROTO_02 program replace what you cut out with
/include QPROTOSRC(PROTO_02)
Now, in the new program that you wrote, that you want to call PROTO_02 you
also include this:
/include QPROTOSRC(PROTO_02)
D nbr1 s 15p 5
D nbr2 s like(nbr1)
then, in your calcs you do a simple
/free
callp PROTO_02(nbr1:nbr2);
or simply the implied callp
PROTO_02(nbr1:nbr2);
II - Subroutine
You meant subprocedure. They are different from a subroutine. See if you
understand this simple program named JAKE, compiled, tested.
h dftactgrp(*no) actgrp(*caller)
D Jake PR EXTPGM('JAKE')
D Input1 15p 5
D Input2 15p 5
D Jake PI
D Input1 15p 5
D Input2 15p 5
D MyCalc PR 5i 0
D SomeNbr1 7p 2 const
D SomeNbr2 7p 2 const
D DsplyVar s 5i 0
/free
*inlr=*on;
// Take the parameters sent to this program, use a simple
// subprocedure to add them together and display the result.
DsplyVar=MyCalc(Input1:Input2);
dsply DsplyVar;
/end-free
P MyCalc B
D MyCalc PI 5i 0
D ThisNbr1 7p 2 const
D ThisNbr2 7p 2 const
/free
return ThisNbr1 + ThisNbr2;
/end-free
P MyCalc E
DSPJOBLOG
CALL PGM(JAKE) PARM(X'000000000100000F' X'000000000200000F')
DSPLY 3
Rob Berendt
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.