Types within types
Blitz3D Forums/Blitz3D Beginners Area/Types within types
| ||
How do you use types within types? I think I read somewhere once that it is possible, however my own attempts at getting it to work have failed miserably. Here's my code. I have a tree type, and an apple type. The tree type is referenced by the apple type, and then I'm trying to access the tree info from the apple object. If anyone can point out what I'm doing wrong that would be much appreciated!! Type tree Field tree_type$ End Type Type apple Field t.tree Field apple_size End Type t.tree=New tree t\tree_type$="big tree" a.apple=New apple a\tree=t.tree ; apple belongs to tree ; Print information about the tree the apple is attached to Print a\tree\tree_type$ ; does not work? WaitKey() |
| ||
apple does not have a field called tree. The field is called t. Change the last two lines to this: a\t=t.tree print a\t\tree_type |
| ||
Yes, that's it, thanks! Working version: Type tree Field tree_type$ End Type Type apple Field t.tree Field apple_size End Type t.tree=New tree t\tree_type$="big tree" a.apple=New apple a\t=t.tree ; apple belongs to tree ; Print information about the tree the apple is attached to Print a\t\tree_type$ ; works WaitKey() |