I use LOCTR heavily in my programs. Separate areas for base code, basr'ed to code, lits, acons, just to name a few. It will not help me with this issue.

The following is the code that uses the AREAD macro that I am working with. The macro is attached. (I have trimmed down the source call a bit as the real one has a lot more entries in the table.

  PERFORM_ON (R3),BAD_VALUE=ERRNO_20000
        INITAPI                 00
        ACCEPT                  01
        BIND                    02
        CLOSE                   03
        CONNECT                 04
        FCNTL                   05
        -----

In reality, I think this is a very appropriate use of AREAD and I am just stuck with only using the macro in real program code and not in another macro.

Tony Thigpen

Seymour J Metz wrote on 5/3/21 4:43 PM:
Depending on what you're doing, LOCTR may help.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Assembler List [[email protected]] on behalf 
of Tony Thigpen [[email protected]]
Sent: Monday, May 3, 2021 3:52 PM
To: [email protected]
Subject: Re: [PossibleSpam] Re: AREAD question

In this case, I am using AREAD to build a branch table. The macro first
edits the value passed based on the number of entries in the branch
table. It needs knows how many entries by reading branch_to points. (It
also builds the table while it is reading/counting the number of
entries.) The number of entries can easily be over 60 in many of my
programs.

Tony Thigpen

Jon Perryman wrote on 5/3/21 3:06 PM:
   AREAD is intended for reading the source file. Although there are 
workarounds, I personally avoid them because you can run into problems with 
macros that use aread. As you mentioned, SETC to a global variable is a good 
option to pass information.
What are the negative issues you encountered with SETC? I've written a lot of 
macro's and never had an issue. Sometimes it's more work than I would like but 
still manageable. For instance, do you really need AREAD or would temporarily 
override opcodes work?
Jon.
      On Monday, May 3, 2021, 08:31:25 AM PDT, Tony Thigpen <[email protected]> 
wrote:

   I have several macros that use AREAD. But, I tried something this
weekend that I still have not figured out. Maybe someone has a suggestion.

I also use macros as a way to include large blocks of common code in
programs. I tried to create such a macro from some code that used one of
my macros that used AREAD. I found that the use of AREAD in the
lower-level macro actually read from the 'top level' program source, not
from the source in the 'next-up' macro.

The doc does indicated that this would happen:
"...from the records in the primary input
stream that follow immediately after the macro instruction."

So, it looks like the only way to use an AREAD and read from an 'higher
level' macro, would be to have the higher level macro push the info to
be read into the buffer using AINSERT. Not as 'nice'.

Did I miss some other option?

(Before you suggest COPY vs. macros for common code, I usually include
parms to the common code. I can re-work that logic using .SETC, etc.,
but that has some negative issues I would need to think about before
doing so.)



Tony Thigpen


         MACRO
&NAME    PERFORM_ON &ADDR,&BAD_VALUE=
.*   SAME AS PERFORM_ON
&GOBAD   SETC  'A&SYSNDX'
         AIF   ('&BAD_VALUE' EQ '' ).NOBV
&GOBAD   SETC  '&BAD_VALUE'
.NOBV    ANOP
         ST    R15,R15_LAST
         MACPARM L,R15,&ADDR
         CL    R15,A&SYSNDX            MUST BE LOGICAL, NOT NBR COMPARE
         BH    &GOBAD                  . BRANCHES FOR BOTH HIGH & MINUS
         LA    R14,3
         NR    R14,R15
*        LTR   R0,R0                           CC SET BY NR   TT 082712
         BNZ   &GOBAD
         L     R15,B&SYSNDX.(R15)
         LTR   R15,R15
         BZ    &GOBAD
         BASR  R14,R15
         B     D&SYSNDX
B&SYSNDX DS    0F
.READ    ANOP
&CARD    AREAD NOSTMT
&FLD     SETC  '&CARD'(16,39)
&COMMENT SETC  '&CARD'(40,30)
         AIF   ('&CARD'(1,1) EQ '*').READ
         AIF   ('&CARD'(16,1) EQ '-').CARDEND
         AIF   ('&CARD'(16,1) EQ ' ').INVALID
         AIF   ('&CARD'(16,3) EQ 'N/A').INVALID
&L       SETA  1
.GETFLD  AIF   ('&FLD'(&L+1,1) EQ ' ').STORE
&L       SETA  &L+1
         AGO   .GETFLD
.INVALID ANOP
&L       SETA  1
&FLD     SETC  '0'
.STORE   ANOP
&WHERE   SETC  '&FLD'(1,&L)
&WHEREX  SETC  'A(&WHERE)                      '(1,24)
         DC    &WHEREX&COMMENT
         AGO   .READ
.CARDEND ANOP
A&SYSNDX DC    X'0000'    FORCE ABEND  | MUST BE TOGETHER FOR THE
C&SYSNDX DC    Y(*-B&SYSNDX-4-2)       | CL TEST TO WORK      TT 050610
D&SYSNDX DS    0H
         MEND

Reply via email to