Check if 2D array not Dim'd

with a ONE dimesional array you can tell if it has been allocated by doing this

if myarray.ubound<0 then [it has not been dimensioned]

So how do you do it with a 2D array?

if myarray.ubound(0)<0 then ' gives an compile error [This array method works only for one-dimensional arrays]

and this

if ubound(myarray,0)<0 then ' gives an out of bounds exception... EVEN if it is dimensioned already

Basically it is a 2D array of booleans… that will have a dynamic size that will change as the program is used…
The idea is to redim it to (-1,-1) and let the routine that updates it decide it it needs to reallocate a new one…
This way when the routine completes, it can “destroy” the array by setting it back to -1,-1

Note : the array is GLOBAL, as there are multiple routines that need to check the flags stored within

Ubound still works
see the other form
result=Ubound(array[,dimension])

so
if ubound(myarray,1) < 0 then ’ gets the unbound of the first dimension

DUH… read the LR a bit more carefully :slight_smile:

if ubound(myarray,1)<0 then 

I’d have posted RTFM but …… :stuck_out_tongue:
You get so used to how thing work that sometimes you overlook things that should be apparent