Forgetting REXX for the moment, COBOL does work pretty much how you say.
Here's an example (irrelevant data omitted).
Called program (CALLEE):
LINKAGE SECTION.
01 MY-PARM PIC X(80).
PROCEDURE DIVISION.
MOVE ALL 'X' TO MY-PARM
GOBACK.
Calling program:
WORKING-STORAGE SECTION.
01 MY-40 PIC X(40).
01 ANOTHER-40 PIC X(40).
PROCEDURE DIVISION.
CALL 'CALLEE' USING MY-40
GOBACK.
(Untested)
Assuming there are no slack bytes between MY-40 and ANOTHER-40, upon return
from CALLEE, both MY-40 and ANOTHER-40 will contain a string of 40 'X'
characters.
If ANOTHER-40 didn't exist and MY-40 was at the end of the caller's
working-storage you'd likely overwrite some important control block.
Not great! But that's how it works.
Enterprise COBOL 6.1 introduced a new compile option called PARMCHECK that does
the following: "When a calling program is compiled with PARMCHECK, the
compiler generates a buffer following the last data item in the WORKING-STORAGE
section. At run time, before each call, the buffer is set to ALL x'AA'. After
each call, the buffer is checked to see whether it was changed. " This helps
detect the "working-storage overflow" issue, but I don't think helps you avoid
overwriting your own working-storage.
________________________________
From: IBM Mainframe Discussion List <[email protected]> on behalf of
Paul Gilmartin <[email protected]>
Sent: Monday, March 22, 2021 4:30 PM
To: [email protected] <[email protected]>
Subject: Re: Can I use a REXX PLIST when calling a COBOL program?
On Mon, 22 Mar 2021 19:41:10 +0000, Jeremy Nicoll wrote:
>On Mon, 22 Mar 2021, at 19:27, Rich Tabor wrote:
>
> LINKAGE SECTION.
> 01 FLD1 PIC X(08).
> 01 FLD2 PIC X(08).
> 01 FLD3 PIC X(20).
> ...
> /* REXX */
> CBLPGM = 'TST01'
> FLD1 = SUBSTR('AAAAAAAAAAAAAAAA',1,80)
> FLD2 = SUBSTR('BBBBBBBBBBBBBBBB',1,80)
> FLD3 = SUBSTR('CCCCCCCCCCCCCCCC',1,80)
> SAY 'FLD1 =' FLD1
> SAY 'FLD2 =' FLD2
> SAY 'FLD3 =' FLD3
> ADDRESS LINKPGM CBLPGM "FLD1 FLD2 FLD3"
>
>
>The logic inside support for "linkpgm" knows that the first value it
>receives is the program name, not a variable containing it, and the
>other values are the name of variables. Linkpgm will )in this case)
>build the parm list with three parm addresses in it.
>
The lengths don't match. Is this an invitation to buffer overflow?
Is it simply incumbent on the programmer to ensure that the
actual parameters are no shorter than the formal parameters?
I assume the names don't matter; only the addresses.
I'm not a COBOL programmer. GIYF -- I found:
http://www.simotime.com/cblpar01.htm
*****************************************************************
LINKAGE SECTION.
01 PARM-BUFFER.
05 PARM-LENGTH pic S9(4) comp.
05 PARM-DATA pic X(256).
*****************************************************************
With declarations of that form, would it work to use ADDRESS LINKMVS
rather than LINKPGM?
-- gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN