types in types

Blitz3D Forums/Blitz3D Programming/types in types

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I know you can make types in types, but run the code below, and you will see the problem im haveing....the comments describe it well i think.

Type forest
	Field t.tree
End Type

Type tree
	Field treetype$
End Type

Global f1.forest=New forest
Global f2.forest=New forest


;make 5 trees in forest 1 and mark them as "green"
For a = 1 To 5
	f1\t = New tree
	f1\t\treetype$ = "green"
Next


;make 5 more trees, but in forest 2 this time and mark them as "brown"
For a = 1 To 5
	f2\t = New tree
	f2\t\treetype$ = "brown"
Next


;now to make my point when looping through the trees in forest 1, there should be no "brown"
;yet it goes through all trees.........anyone know how to go around this/or am i doing something wrong?
;should it look like this somehow in the for loop ?
;For f2\t = Each f2\t.tree   ???? or
;for f2\t = Each tree in f2

For f2\t = Each tree
	Print f2\t\treetype$
Next

WaitKey