Variance of the previous workaround, using such a Type structure containing a similar array, but in addition to the user array, the structure being placed at the same address as the user array itself:
Code: Select all
dim as integer arr(1 to 10) = {1,2,3,4,5,6,7,8,9,10}
Print arr(10)
type UDT
dim as integer array(1 to 10)
end type
dim as UDT ptr parr = cptr(UDT ptr, @arr(1))
*parr = type({2,3,5,7,11,13,17,19,23,29})
print arr(10)
*parr = type({3,5,8,11,16,19,24,27,32,39})
print arr(10)
sleep
or (more generic code):
Code: Select all
dim as integer arr(1 to 10) = {1,2,3,4,5,6,7,8,9,10}
Print arr(10)
type UDTarr
dim as typeof(arr) array(lbound(arr) to ubound(arr))
end type
dim as UDTarr ptr parr = cptr(UDTarr ptr, @arr(lbound(arr)))
*parr = type({2,3,5,7,11,13,17,19,23,29})
print arr(10)
*parr = type({3,5,8,11,16,19,24,27,32,39})
print arr(10)
sleep
or (if you prefer use a reference instead of a dereferenced pointer):
Code: Select all
dim as integer arr(1 to 10) = {1,2,3,4,5,6,7,8,9,10}
Print arr(10)
type UDTarr
dim as typeof(arr) array(lbound(arr) to ubound(arr))
end type
dim byref as UDTarr rarr = *cptr(UDTarr ptr, @arr(lbound(arr)))
rarr = type({2,3,5,7,11,13,17,19,23,29})
print arr(10)
rarr = type({3,5,8,11,16,19,24,27,32,39})
print arr(10)
sleep