Pointers to types

BlitzMax Forums/BlitzMax Programming/Pointers to types

Ant(Posted 2005) [#1]
Hi, I want to store a pointer to a type within another type but cant figure out where I'm going wrong. Also when I have the pointer to the type, how do I access fields in the type that the pointer points to?



Thanks


Ant(Posted 2005) [#2]
sorry, stupid copy/paste error/Final line should be

newtest.test=Varptr Newprop.

Still unsure if I can change the fields of newprop via the newtest.test pointer though?


bradford6(Posted 2005) [#3]
Type TProperties
	Field name:String
	Field Weight:Int		
	Field force:Int				
	Field material:Int				
	Field move:Int				
	Field state:Int	
End Type

Type TThing
	Field properties:Tproperties
	
End Type



Local my_thing:Tthing = New Tthing
'Local my_thing.properties:Tproperties = New Tproperties
Local my_properties:Tproperties = New Tproperties

my_thing.properties = my_properties

my_thing.properties.name = "Melvin"
my_thing.properties.weight = 500
my_thing.properties.force = 30

Print my_thing.properties.name+" weighs "+my_thing.properties.weight+" lbs and generates "+my_thing.properties.force+" lbs of force"





Azathoth(Posted 2005) [#4]
Use '[0]' to see the contents of a pointer.
In this case it would be 'newtest.test[0]' and whatever field you want to access.


bradford6(Posted 2005) [#5]
you can click edit and change the code in this forum Ant.


Ant(Posted 2005) [#6]
Thanks for all the help guys - keep forgetting about the edit!