Adress from array

BlitzMax Forums/BlitzMax Programming/Adress from array

MrCredo(Posted 2007) [#1]
local array:int[10]

and now i need the mem-address from value of array[0]

how to get it?


Azathoth(Posted 2007) [#2]
Just 'array' should give the pointer.


MrCredo(Posted 2007) [#3]
i think this works


Local array:Byte[10]
array[0]=123

mem=Int(Varptr(array[0]))
Print mem

Local zero:Byte Ptr
Print zero[mem]


Azathoth(Posted 2007) [#4]
or easier way:
Local array:Byte[10]
array[0]=123

Local mem:Byte Ptr=array

Print mem[0]



Gabriel(Posted 2007) [#5]
This will only work with simple datatypes, of course, as BlitzMax does not store object arrays in contiguous memory. It stores only pointers to those objects in the array and the objects elsewhere. Which makes sense being that types are always passed by reference, never by value, but I just thought it might be worth pointing out in case someone spots this thread and assumes object arrays work the same way.