Types in Types

Blitz3D Forums/Blitz3D Programming/Types in Types

GeordieB(Posted 2005) [#1]
Hey all,
Just wondering, while i know how to make a type in a type, what i dont know is how you'd would do a For..loop within this type in a type, if you know what i mean

so like say you had 2 types, and one variable in the first type was linked to another type, and you did lots of "g\c=New t" ect, how would you (or can you) do a for... loop within only the types added to this single g\c, without the loop going through EVERY type "t"......

Cheers


Braincell(Posted 2005) [#2]
Here is a bit of code i had recently tested about, and i'll tell you what i got from it:



I'm not sure what you mean by: "one variable in the first type was linked to another type" but i think what you are asking is can you set boundaries by assigning to certain variables?

In my case the code:


For c\Column.Colection = Each Colection
	orr=orr+1
	Print "top-----: " + c\Column\top + " bot: " + c\Column\bottom + " order: " +orr
	Next



worked just the same regardless if you put it within the other For loop. It does not recognize inside which "variable" of the type above it it was created in, and it does Not set up boundaries.

Hope that answers something. :)


GeordieB(Posted 2005) [#3]
your example shows what im trying to avoid, in that i need a way to go through only the "colection" items that are created under, for example, the 5th "list", rather than having to go through the entire colection type picking out the ones i want, as this makes the whole process of types in types pointless imo


Duckstab[o](Posted 2005) [#4]
sorry me bad:)


Stevie G(Posted 2005) [#5]
Bonks,

Not clear what you want but if you want to associate each item to a list , iterate through all the items and just display those which relate to a specific list then you can use something like this ....

Graphics 800,600

Type ListType
	Field x,y,z
End Type

Type ItemType
	Field Name$
	Field Size
	Field ListRef.ListType
End Type


LIST1.ListType = CREATElist ( 5, 4, 5 , 10 )
LIST2.ListType = CREATElist ( 5, 4, 5 , 10 )
LIST3.ListType = CREATElist ( 5, 4, 5 , 10 )
LIST4.ListType = CREATElist ( 5, 4, 5 , 10 )
LIST5.ListType = CREATElist ( 1, 1, 1 , 5 )

SHOWitems_in_list( LIST1 )
SHOWitems_in_list( LIST2 )
SHOWitems_in_list( LIST3 )
SHOWitems_in_list( LIST4 )
SHOWitems_in_list( LIST5 )

MouseWait

End

;============================================
;============================================
;============================================

Function SHOWitems_in_list( l.ListType )

	For i.ItemType = Each ItemType
		If i\ListRef = l
			Print i\Name + "     "+i\Size
		EndIf
	Next

End Function

;============================================
;============================================
;============================================

Function CREATElist.ListType( x, y, z, items )

	l.ListType = New ListType
	
	For item = 1 To items
		CREATEitem( l ,"Test"+Str$(item) , Rand(10) )
	Next
	Return l

End Function

;============================================
;============================================
;============================================

Function CREATEitem( l.Listtype , Name$ , size )

	i.ItemType = New ItemType
	i\Name = Name$
	i\Size = size
	i\ListRef = L
	
End Function