This is more or less what I am trying to do (second paragraph). Here's a
"real world" example of what I am doing:
MACRO
&LABEL KEYFIELD &NAME,&FIELD,&TYPE=C,&DSECT=NO
AIF ('&DSECT' EQ 'YES').KEYFIELD_DSECT
&N SETC '&NAME'
&F SETC '&FIELD.-BASE'
&L SETC 'L''&FIELD'
&KEYNAME SETC ' '
&KEYDISP SETC ' '
&KEYDLEN SETC ' '
&KEYTYPE SETC ' '
&LABEL DS 0F
AGO .KEYFIELD_GEN
.KEYFIELD_DSECT ANOP ,
&N SETC ' '
&F SETC '0'
&L SETC '0'
&KEYNAME SETC 'KEYNAME '
&KEYDISP SETC 'KEYDISP '
&KEYDLEN SETC 'KEYDLEN '
&KEYTYPE SETC 'KEYTYPE '
KEYFIELD DSECT ,
.KEYFIELD_GEN ANOP ,
&KEYNAME DC CL8'&N'
&KEYDISP DC A(&F) OFFSET TO FIELD
&KEYDLEN DC A(&L) FIELD LENGTH
&KEYTYPE DC CL1'&TYPE' FIELD TYPE
DS 0F
AIF ('&DSECT' EQ 'NO').KEYFIELD_END
KEYLEN EQU *-KEYFIELD
.KEYFIELD_END ANOP ,
MEND
This is how I'm creating "anonymous" fields in the code expansion and
labeled fields in the DSECT. If there is a better way, I never figured
that out or have forgotten what I did.
*Mark*
On Fri, Jun 20, 2025 at 4:46 AM Jonathan Scott <
[email protected]> wrote:
> You'd be amazed at what can be done using OPSYN to intercept DC, DS, ORG
> and EQU! I've previously written tools to support "object oriented"
> assembler "class" definitions where the data definitions are mostly just
> ordinary DC or DS and can even include IBM macros. Remember also that DC
> within a DSECT is treated quite similarly to DS, which helps. If the class
> definition is copied into a module which is not the "owner" or a "friend"
> as listed in the class header, all private variables and methods are
> automatically made anonymous or renamed to internal names so that they
> cannot be referenced within that module. But admittedly that stuff was
> very tricky to set up and it took a lot of work to make it sufficiently
> reliable, robust, well-documented and maintainable to be suitable for
> official product code, so it's not really a quick solution.
>
> If you have multiple instances of some structure, perhaps including
> initial values as well as dynamic copies, I would recommend that rather
> than defining prefixed labels for each instance it would be much better to
> use anonymous fields except for the standard DSECT then to use qualified
> USING statements to refer to the fields in each copy as required.
>
> Jonathan Scott
>
>
>
>
>
>