Dynamic arrays are complicated, but the macros can be held in a library.
macro DynamicArray(t,v,n)
t*v
@v=getmemory n*sizeof t
end macro
macro DynamicRedim(t,v,n)
scope (
sys p=@v
indexbase 0
sys le=*p[-1] 'length of original
@v=getmemory n*sizeof t 'new mem block
if le>n*sizeof t
le=n*sizeof t 'clip data length to fit
end if
if le
copy @v,p,le 'copy data
end if
freememory p
)
end macro
'================
indexbase 0
sys nx=100,ny=50
DynamicArray double,d,nx*ny
macro da(x,y) d(x+y*nx)
da(50,10)=123
DynamicRedim double, d, nx*ny*2
print da(50,10)
'freememory @d
DynamicRedim double, d, 0 'void array
Charles