TYPE within TYPE

BlitzPlus Forums/BlitzPlus Programming/TYPE within TYPE

If you want each type instance to contain its own personal list of sub-types (so in your example each B having its own list of A types), you need to use either linked lists or a type array. A type array would look like the following:

Type B
Field something
Field c.A[20]
End Type

the downside is you have to specify how many types are contained in the array ahead of time, and you cannot redimension the type array.

A linked list would look like the following:

Type A
Field something
Field parent.a
Field child.a
End Type

Type B
Field something
Field first.A
End Type

The first.A type would contain a pointer to the first A type in the list, and then each successive A type would point to the next type in the list and the previous type in the list.

The benefit of this method is that you can add and subtract types dynamically, the downside is that its more complicated to keep track of.

Either method requires custom functions to add/remove/iterate through the list of A types, you won't be able to use Blitz's first, last, next, each etc.