swapping array pointers

BlitzMax Forums/BlitzMax Programming/swapping array pointers

Nate the Great(Posted 2010) [#1]
suppose I have the following code...

Local t1:Float[100]
Local t2:Float[90]

Print t1.length
Print t2.length
swap(t1,t2)
Print t1.length
Print t2.length

Function swap(x0:Float[],x:Float[])
	Local tmp:Float[] = x0
	x0 = x
	x = tmp
End Function


this obviously prints the following when run

100
90
100
90

I need this output to show the pointers are swapped

100
90
90
100

but I need my swap function to somehow swap the pointers and I just went brain dead on how to use pointers, does anyone know how I can go about making this swap function?


Czar Flavius(Posted 2010) [#2]
The parameters x0 and x are local to the function and discarded when the function ends, leaving the variables outside untouched. I think you need to put Var on the end (x:Float[] Var) but I'm no expert on it.


Nate the Great(Posted 2010) [#3]
thank you czar flavius!!!!!!!!!!!

that was exactly what I was trying to remember but it just slipped my mind, it works now.