Pointers to types
BlitzMax Forums/BlitzMax Programming/Pointers to types
| ||
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 |
| ||
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? |
| ||
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" |
| ||
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. |
| ||
you can click edit and change the code in this forum Ant. |
| ||
Thanks for all the help guys - keep forgetting about the edit! |