Thank you, Jerome!

I expected the memory allocation to be consistent for the second dimension of ARRAY-2 (similar to a Periodic Group), but I also expected *OCC (ARRAY-2) to match Peter’s COUNT-2 value (ARRAY-2 acting as a set of MUs). Jerome’s posting has helped me to see that the latter was completely ridiculous, as the syntax doesn’t allow it.

```
*OCC (PDA-1.ARRAY-2, 2) /* valid
*OCC (PDA-1.ARRAY-2 (#I) ,2) /* invalid
```

I’m disappointed that X-arrays act like PEs instead of MUs. For the first dimension, *UBOUND is the memory allocation and *OCC is the number of used positions. For the second and third dimensions, *OCC will always match *UBOUND - not very useful.

To populate the first array, Peter will need to maintain the COUNT-2 field to use it as an index. *OCC should be used for the EXPAND, as it represents a maximum count for the second dimension. Otherwise, he would need to calculate the maximum value of COUNT-2 (*) for the EXPAND. (Or use the (more expensive) FOR loop from my previous post.)

I wanted to compare COUNT-2 to *OCC, so I populated the table with

```
EXPAND ARRAY PDA-1.ARRAY-1 TO (1:5)
FOR #I = 1 TO 5
MOVE #I TO PDA-1.FIELD-1 (#I)
MOVE #I TO PDA-1.COUNT-2 (#I)
EXPAND ARRAY PDA-1.ARRAY-2 TO (*,1:#I)
MOVE #I TO PDA-1.ARRAY-2 (#I, 1:#I)
END-FOR
```

Then displayed the contents

```
DISPLAY *OCC (PDA-1.FIELD-1) (NL=2)
PDA-1.FIELD-1 (*)
*UBOUND (PDA-1.ARRAY-2, 2) (NL=2)
*OCC (PDA-1.ARRAY-2, 1) (NL=2) /* 1st dimension
*OCC (PDA-1.ARRAY-2, 2) (NL=2) /* 2nd dimension
PDA-1.COUNT-2 (1)
PDA-1.ARRAY-2 (1, *)
PDA-1.COUNT-2 (2)
PDA-1.ARRAY-2 (2, *)
PDA-1.COUNT-2 (3)
PDA-1.ARRAY-2 (3, *)
PDA-1.COUNT-2 (4)
PDA-1.ARRAY-2 (4, *)
PDA-1.COUNT-2 (5)
PDA-1.ARRAY-2 (5, *)
```

to get this

```
OCC FIELD-1 UBOUND OCC OCC COUNT-2 ARRAY-2 COUNT-2 ARRAY-2 COUNT-2 ARRAY-2 COUNT-2 ARRAY-2 COUNT-2 ARRAY-2
--- ---------- ------ --- --- ------- ---------- ------- ---------- ------- ---------- ------- ---------- ------- ----------
5 1 5 5 5 1 1 2 2 3 3 4 4 5 5
2 2 3 4 5
3 3 4 5
4 4 5
5 5
```

And lastly, Jerome’s code has a minor bug.

`MOVE *OCC(PDA-1.ARRAY-2) TO #I`

should be

`MOVE *OCC(PDA-1.ARRAY-2, 2) TO #I /* 2nd dimension`