01-24-2025, 04:45 PM
I guess you could always try something like this:
Then you'd call it with:
foo _OFFSET(array()), LBound(array), UBound(array), "LONG"
And you can build your array from there.
Code: (Select All)
SUB Foo (o AS _OFFSET, start, finish, data_type AS STRING)
DIM AS _MEM m, m1
SELECT CASE data_type
CASE "LONG": element_size = 4: mem_total = (finish - start + 1) * element_size
CASE 'others
END SELECT
m = _MEM(o, mem_total)
SELECT CASE data_type
CASE "LONG": DIM a(start, finish) AS LONG
CASE 'others such as integer, float, single, whatever...
END SELECT
m1 = _MEM(a())
_MEMCOPY m, m.offset, mem_total TO m1, m1.offset 'copy the original array to the array a() in the sub, of the desired type necessary
'do stuff with a()
_MEMFREE m
_MEMFREE m1
END SUB
Then you'd call it with:
foo _OFFSET(array()), LBound(array), UBound(array), "LONG"
And you can build your array from there.
