Prior to this APAR, I was forced to do the SETA against the equate before the 
macro call and then pass the resolved value into the macro i.e.

&L       SETA  equ_name
         MacroName LEN=&L

The ability to do the SETA inside the macro really simplifies our code, but 
it's implementation seem to be somewhat flaky. Sometimes it work, other times 
it get errors.

TestSETA TITLE 'Test LEN macro'
         MACRO
         BLAH &FLD
         AGO   .AAm040
         AIF   (D'&FLD).AAm030
         MNOTE 4,'&FLD is not defined'
         AGO   .AAm040
.AAm030  ANOP  ,
         MNOTE 0,'&FLD is defined'
.AAm040  ANOP  ,
&L       SETA  &FLD
         MNOTE 0,'Length of &FLD is &L'
         MEND  ,
         IHASAVER ,
TestSETA RSECT
         BLAH  SAVF4SA_Len
         BLAH  Saver_Len
         END

This code above assembles correctly, but if you comment out the AGO on line 4, 
it fails assembly???

Robert Ngan
DXC Luxoft


-----Original Message-----
From: IBM Mainframe Assembler List <[email protected]> On Behalf 
Of Jonathan Scott
Sent: Friday, November 17, 2023 16:22
To: [email protected]
Subject: Re: Macro variable attributes

> Is there a way to know the real value of the LEN below when I use a
> variable instead of a value?
>
>      MACRO
> &LABEL WORK &LEN=0
> &LABEL DS XL(&LEN)
>      MNOTE *,.LEN=&LEN.
>      MEND

If you have a recent maintenance level of HLASM, including APAR
PH34116 from February 2021, you can use SETA to obtain the value of an equated 
symbol which has been defined and resolved.  (Some parameter cases did not work 
and required a further fix for APAR PH50923).

So in this case, if you know that &LEN contains a single symbol which has been 
defined and resolved before the macro is invoked, you can simply use something 
like:

&N      SETA  &LEN

If it contains a more complex expression, you can use EQU to create a dummy 
variable equal to the expression and then use that in a SETA expression, 
provided it has been resolved.

It is possible to test whether a symbol is defined using the defined attribute 
D'&LEN but unfortunately it is not currently possible to test whether it has 
been resolved (which may not be the case if the EQU expression contains forward 
references), so I do not think it is possible to write code which will assemble 
without error but which will only conditionally extract the value if it has 
already been resolved.

Jonathan Scott, HLASM
IBM Hursley, UK

Reply via email to