Pointing to array at an offset?

BlitzMax Forums/BlitzMax Programming/Pointing to array at an offset?

ImaginaryHuman(Posted 2006) [#1]
How do I have one array pointer, from an empty array, point to the middle of another existing array?

e.g. something like

Local MyArray:Float[10]
Local DummyArray:Float[]
Varptr(DummyArray)[0]=Varptr(MyArray[5])

Obviously that's not right, but you get the idea.

???? I want to be able to point a temporary array pointer to the middle of a large existing array so that I can then read from the temp array as if offset 0 is in the middle of the original array, so that offsets indexes are simplified, without copying the array or creating a new one.


gman(Posted 2006) [#2]
if it doesnt have to be Float[]
SuperStrict
Framework brl.basic

Local MyArray:Float[10]
MyArray[0]=10
MyArray[1]=11
MyArray[2]=12
MyArray[3]=13
MyArray[4]=14

Local DummyArray:Float Ptr
DummyArray=Varptr(MyArray[2])

Print DummyArray[0]
Print DummyArray[1]



ImaginaryHuman(Posted 2006) [#3]
Hey, excellent, thanks!

I was having to do array[offset+index] in a loop and didn't want to have to keep adding the offset all the time when it doesn't change.