Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any better way around Duplicate Definition problems?
#5
I guess you could always try something like this:

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. Tongue
Reply


Messages In This Thread
RE: Any better way around Duplicate Definition problems? - by SMcNeill - 01-24-2025, 04:45 PM



Users browsing this thread: 1 Guest(s)