Thanks, Abe.

I documented the technique to read a COPY book with AREAD in response to 
a previous requirement documented in the "Ideas" tool (which needs IBM id 
to access):
https://ideas.ibm.com/ideas/HLASM-I-1

If I remember correctly, the COPY statement will still be seen by the AREAD, 
but it will be followed by the copy book contents.  The AINSERT statements
should be processed in the order shown below, but can either be issued in
the same order with the BACK option (which I prefer) or in reverse order 
with the FRONT option.

Unfortunately the "Ideas" tool stripped out a lot of spaces, requiring some 
reconstruction for valid assembler.  Here's what it should have said (it will
look best with a monospaced font):

There is an existing technique to allow a COPY file to be processed via AREAD, 
which is to cause the COPY file to be fetched by lookahead by using a forward 
attribute reference, so the AREAD will see the contents of the copy file rather 
than the COPY statement itself. This can all be encapsulated in a macro, using 
AINSERT to create an end label and issue the COPY, for example something 
like the following:

         MACRO
         MYCOPY &MEMBER
&ENDLABEL SETC 'ENDCOPY_&SYSNDX'
         AINSERT ' READMEM &ENDLABEL',BACK
         AINSERT ' COPY &MEMBER',BACK
         AINSERT '&ENDLABEL DS 0X',BACK
         MEND

         MACRO
         READMEM &ENDLABEL
&T       SETC  T'&ENDLABEL     Cause lookahead
.LOOP    ANOP  ,
&LINE    AREAD ,               Read next input line
         AIF   ('&LINE'(1,K'&ENDLABEL+1) EQ '&ENDLABEL ').END
         ...                   Process input line
         AGO   .LOOP
.END     ANOP  ,
         MEND

         MYCOPY MEM1

Jonathan Scott

Reply via email to