Re: Re: MVT COBOL under MVS3.8j.

"Giuseppe Vitillaro giuseppe-yuD/ahkh7LvrZ44/[email protected] [H390-MVS]" <[email protected]>
Newsgroups gmane.comp.emulators.hercules390.mvs
Message-ID <[email protected]>
On Tue, 16 Sep 2019, [email protected] [H390-MVS] wrote:

>> PLI is the more accessible way, if I got it correctly?
>
> Look on page 118 of the PL/I Programmers' Manual (GC28-8201-4).
>
> Even there, it is a kluge (read into a varying variable and take its LENGTH()).
>
> I wanted to replicate a program I wrote in BAL one afternoon (about 35 
> years ago) to compare text files (two source control systems neither 
> offering the feature), so I had to look up this particular facet of 
> PL/I.
>
> In order to control the varying record lengths on output, of course, the 
> runtime takes the length of the variable being written out.
>
> And along the way, wrote yet another interface subroutine, letting COBOL 
> do little things like read-backwards and use everything BAL could for 
> VSAM files.
>
> Laird Heal

Like this?

LOOP:
     DO;
       READ FILE(VSDS) INTO(BUF);
       NR = NR + 1;
       L = LENGTH(BUF)+4;
       T=T+L;
       IF ( PARM ¬= 'NOREC' ) THEN
       PUT SKIP EDIT('Record N.',NR,'Length:',L)
                (
                  COL(1),A(10),
                  COL(15),F(8),
                  COL(25),A(10),
                  COL(35),F(8)
                );
       WRITE FROM(BUF) FILE(VSDS1);
       GOTO LOOP;
     END;

Yep, I know how to manage RECFM=V(B/S) in PLI. This simple
fragment is enough to COPY an IEBCOPY RECFM=VS dataset correctly
in PLI. IEBCOPY accept the copied datasets as is SYSUT1 and
correctly restore the original PDS, so, the code, should
be correct.

Beside that, I was curious about how to do it in COBOL.

I've read somewhere it is possible to use a "negative index"
to OCCURS items in cobol, fooling the compiler to access
a negative offset.

I guess, if this is possible in COBOL'68, a REDEFINES may
do the trick?

Peppe.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.