Inspired by Mr. Gilmore, et al, here's my contribution of a simple macro
that makes using the EDIT instruction considerably simpler:

          MACRO
 &LABEL   EDIT &TARGET,&SOURCE,&MASK,&D=9,&S=S,&F=F
 &A       SETA  2                       START POS
 &Z       SETA  K'&MASK-1               END POS
 &XMASK   SETC  ''                      INITIAL MASK
 .MLOOP   AIF   (&A GT &Z).MDONE
 &C       SETC  '&MASK'(&A,1)           GET THIS CHAR
          AIF   ('&C' EQ '&D').DIGIT
          AIF   ('&C' EQ '&S').SIGSEL
          AIF   ('&C' EQ '&F').FLDSEL
 &H       SETC  C2X('&C')
          AGO   .SETCHAR
 .DIGIT   ANOP
 &H       SETC  '20'
          AGO   .SETCHAR
 .SIGSEL  ANOP
 &H       SETC  '21'
          AGO   .SETCHAR
 .FLDSEL  ANOP
 &H       SETC  '22'
 .SETCHAR ANOP
 &XMASK   SETC  '&XMASK&H'
 &A       SETA  &A+1                    NEXT POS
          AGO   .MLOOP
 .MDONE   ANOP
 &LABEL   MVC   &TARGET,=X'&XMASK'
          ED    &TARGET,&SOURCE
          MEND

Example: EDIT  &prefix.Z,&prefix.P,' 999S9**'  Expand nesting level
0000015C D207 C884 A920 00000884 00000920   1630+         MVC
T3_SubDepZ,=X'4020202021205C5C'                          04-EDIT
00000162 DE07 C884 C881 00000884 00000881   1631+         ED
T3_SubDepZ,T3_SubDepP                                    04-EDIT


This is admittedly a minimalist implementation.  A lot could be done to
build on it, depending on your tastes in documentation, error-checking,
other options, etc.  I figure that anyone here can figure it out, and
change it as they see fit.  I'm planning on a variation for EDMK... just
haven't decided exactly how yet.

-- 
sas

Reply via email to