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.

Here is a bit of code i had recently tested about, and i'll tell you what i got from it:


Graphics 800,600

Type List
	Field Column.Colection
End Type

Type Colection
	Field top
	Field bottom
End Type

Columns=10




;create the list
For count=1 To Columns
c.List = New List
Next 
count=0

;now set certain variables
tc=0
For c.List = Each List
;this sets a new collection for each column. Colections can also be cycled.
cols=2
	For count=1 To cols 
	c\Column = New Colection 
	c\Column\top=tc
	c\Column\bottom=5
	Next 
tc=tc+1
Next




Print "Startin prt"

For c.List = Each List ;here is how to iterate through each colection in a column
	For c\Column.Colection = Each Colection
	orr=orr+1
	Print "top-----: " + c\Column\top + " bot: " + c\Column\bottom + " order: " +orr
	Next
Next

Print "done"

WaitKey





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. :)