Another idea is to DIM it one larger than it needs to be and store the lengths in the first elements. So, if you require a 5 x 10 array, instead of DIM A[5,10], use DIM A[6,11], then store the real data in [1,1] through [5,10], and store the size of the first dimension (5) in [0,1], and the size of the second dimension (10) in [1,0]. Yes, for larger arrays it'll result lots of wasted memory.