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.

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