Assuming the various &FIELDS can not safely be presumed to be in
contiguous storage [in this case generated as declares, via the DCLF CL
command within the CLP source], and I expect they can not, then the
following code lays out conceptually, how to setup redefinition of the
variables from the fields in the DSPF, such that later references can be
made using array-like DOWHILE or DOFOR processing. The idea is to use
based storage for each of the like-defined variables and use pointer
addressing to refer to each, making the pointers align in contiguous
storage for an effective array. The following is untested both for
compile [CRTCLPGM] and run [CALL] because I have no system on which to
test].
<code>
Dcl &MbrDta *char stg(*based) len(10) basptr(&MD)
Dcl &FlgDta *lgl stg(*based) basptr(&FD)
Dcl &MD *ptr stg(*based) basptr(&Mptr)
Dcl &FD *ptr stg(*based) basptr(&Fptr)
Dcl &Mptr *ptr stg(*auto) /* value(%addr(&MDary 0001)) */
Dcl &Fptr *ptr stg(*auto) /* value(%addr(&FDary 0001)) */
/* Note: expressions not allowed in LEN(); the expression */
/* is shown to emphasize the origin for the value */
Dcl &MDary *char stg(*auto) len(16*60) /* 16-byte aligned */
Dcl &MD01 *ptr stg(*defined) defvar(&MDary 0001) /* 0000 */
value(%addr(&MEMBER01))
Dcl &MD02 *ptr stg(*defined) defvar(&MDary 0017) /* 0010 */
value(%addr(&MEMBER02))
Dcl &MD03 *ptr stg(*defined) defvar(&MDary 0033) /* 0020 */
value(%addr(&MEMBER03))
...
Dcl &MD60 *ptr stg(*defined) defvar(&MDary 0945) /* 03B0 */
value(%addr(&MEMBER60))
Dcl &FDary *char stg(*auto) len(16*60) /* 16-byte aligned */
Dcl &FD01 *ptr stg(*defined) defvar(&FDary 0001) /* 0000 */
value(%addr(&IN01))
Dcl &FD02 *ptr stg(*defined) defvar(&FDary 0017) /* 0010 */
value(%addr(&IN02))
Dcl &FD03 *ptr stg(*defined) defvar(&FDary 0033) /* 0020 */
value(%addr(&IN03))
...
Dcl &FD60 *ptr stg(*defined) defvar(&FDary 0945) /* 03B0 */
value(%addr(&IN60))
DclF MemberFile /* DSPF w/ Flds MEMBER## and Inds IN## 01-60*/
/* Note: I do not think the DCL can use %addr, so run-time */
/* successive CHGVAR VALUE(%addr(&var##)) requests */
/* must effect the initialization of &xD## pointers; */
/* seriously debasing value of the implementation :-( */
/* Init would go here, before using &Fptr and &Mptr */
InitAllInd: /* Set all IND## to '0'; setting off indicators */
DOFOR VAR(&COUNTER) FROM(1) TO(60) BY(1)
/* Address each MEMBER entry according to the counter */
/* I like ptr=%addr+%ofs but IIRC must %ofs(ptr)=%ofs(p)+x */
/*chgvar &Fptr ( %addr(&FDary) + %ofs((&counter - 1) * 16 ) )*/
chgvar %ofs(&Fptr) (%ofs(&Fptr) + ( (&counter - 1) * 16 ) )
chgvar &FlgDta VALUE('0') /* turn off this indicator */
ENDDO
ChgVar &Fptr value(%addr(&FDary)) /* reset to first? */
CHGVAR VAR(&MEMBER_FLG) VALUE('0')
TstNonBlnk: /* Find if any MEMBER## has a non-blank value */
DOFOR VAR(&COUNTER) FROM(1) TO(60) BY(1)
/* Address each FLAG entry according to the counter */
/* I like ptr=%addr+%ofs but IIRC must %ofs(ptr)=%ofs(p)+x */
/*chgvar &Mptr ( %addr(&MDary) + %ofs((&counter - 1) * 16 ) )*/
chgvar %ofs(&Mptr) (%ofs(&Mptr) + ( (&counter - 1) * 16 ) )
if (&MbrDta *NE ' ') THEN(DO)
chgvar &MEMBER_FLG VALUE('1') /* this one is non-blank */
leave CmdLbl(TstNonBlnk) /* at least one is non-blank */
ENDDO
ENDDO
ChgVar &Mptr value(%addr(&MDary)) /* reset to first? */
</code>