[futurebasic] Dynamic Array with multiple subscripts

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2002 : Group Archive : Group : All Groups

From: Staz <staz@...>
Date: Fri, 29 Mar 2002 09:28:26 -0600
>> Thank you. You are quite right. This is the first time I have used Dynamic
>> arrays and I didn't even think to calculate the allocation because I thought
>> it was a theoretical number. Now I understand.
>> Many thanks again
>> Barrie  
>> 
> Barrie,
> 
> You are correct!--it IS a theoretical number. The compiler doesn't care
> to what size you dimension a dynamic array. Most of them are DIMmed to
> _Maxlong, which is also more ram than any of us have on our machines.
> 
> The problem is with the 2-D array. Dynamic arrays are limited to one
> dimension. To get around this, I have always used a dynamic array of
> dynamic handles and the following fn. I can send a short demo
> illustrating its use if you like.
> 

I don't agree with this, jay. dynamic arrays can have 2 (or 3 or 4 or 5)
subscripts. the first problem in this case is that the second element in the
array is 100001*256 bytes away from the first. the next problem is that it
creates a number for the final offset that is too large for the compiler to
comprehend and check against. the following program proves that 2
dimensional dynamic arrays work as expected.

dynamic a(10,20)
dim x,y

for x = 0 to 10
for y = 0 to 20
a(x,y) = x*y
next
next

for x = 0 to 10
print a(x,x)
next

stop