Consider

|&F1id setc '__F1'   --array 1 identifier
|&F2id setc '__F2'   --array 2 identifier
|&F3id setc '__F3'   --array 3 identifier
|        gblc  &(&F1id)(1)   --declare array 1 w/o giving it elements
|        gblc  &(&F2id)(1)   --declare array 2 w/o giving it elements
|        gblc  &(&F3id)(1)   --declare array 3 w/o giving it elements
|&(&F1id)(1) setc 'a','b','c'  --initialize/create first 3 elements of array 1
|&(&F2id)(1) setc 'd','e','f'   --initialize/create first 3 elements of array 2
|&(&F3id)(1) setc 'g','h','i'   --initialize/create first 3 elements of array 3
|&idaid(1) setc '&F1id','&F2id'.'&F3id'   --array of array identifiers
|&arraysn seta n'&idaid  --number of array identifiers
|&i      seta  0                  --initialize arrays index
|.arrays_loop anop  ,      --top of arrays loop
|&i      seta  &i+1            --increment arrays index
|&eoa setb  (&i gt &arraysn)   --arrays exhausted?
|          aif     (&eoa).arrays_lend    --if so, leave arrays loop
|&aident  setc  '&(&idaid)(&i)'  --identifier of array &i
|&elemsn seta n'&(&aident)     --element count array &i
|&j       seta  0                 --initialize elements index
|.elems_loop                   --top of array &i elements loop
|&j       seta  &j+1            --increment elements index
|&eoe  setb  (&j gt &elemsn)   --elements of array &i exhausted?
|           aif    (&eoe).elems_lend    --if so, leave elements loop
|&label setc 'F'.'&i'.'&j'    --DC label
|&target setc '&(&aident)(&j)'   --DC target value
|&label DC C'&target'
|           ago  .elems_loop  --next element da capo
|.elems_lend anop  ,      --bottom of elements loop
|           ago  .arrays_loop  --next array da capo
|.arrays_lend anop  ,     --bottom of arrays loop
| . . .

The only thing problematic about this is the statement

|&label setc 'F'.'&i'.'&j'    --DC label

Suppose you have

0 < &i < 15
0 < &j < 30

within these loops.  Then element 29 of array 1 will have the  label
'F'.'1'.'29'  or F129, and element 9 of array 12 will have the label
'F'.'12'.'9' = F129 too.

This sort of thing can be dealt with easily using the A2D builtin
function and leading-zeros padding to ensure that the character
representations of &i all have the same number of digits and that
those of &j all have the same perhaps different number of digits.  I
can elaborate on this if it seems opaque.

What needs to be emphasized about these constructions is that while
they seem to be intolerably detail-ridden when first encountered one's
cat brain takes over very quickly.  They become very easy to use with
practice.

John Gilmore, Ashland, MA 01721 - USA

Reply via email to