Something funky is going on when using the same variable to create new objects multiple times. Can anyone figure this one out?
Thanks.
Type T Field x End Type Local a:T Local p1:T Ptr ' A pointer to T. Local p2:T Ptr ' Another pointer to T. ' Set up first object. a = New T a.x = 10 p1 = VarPtr a ' Store address of first object. Print p1[0].ToString() ' Prints address 0x18029f8. OK. ' Set up second object using same variable. a = New T a.x = 20 p2 = VarPtr a ' Store address of second object. Print p2[0].ToString() ' Prints 0x1802a28. Different address. Good! Print p1[0].ToString() ' Prints 0x1802a28. Wha happen?? Why did it change? Print p2[0].ToString() ' Prints 0x1802a28. Print p1[0].x ' Prints 20 due to mem address change. Don't want this to happen! Print p2[0].x ' Prints 20. OK.
Thanks.