Hm. One way you could do that would be to give some sort of identifier so the children knew which parent they belonged to. Right now only the parent knows which child he has created last (you're overwriting the child pointer with every new child created) and thus theres no way to do what you want with the way you're representing your data.
One way would be to have an integer field in your parent type, "children" or something, which would contain a handle to a bank. I've suggested a bank because they can be dynamically allocated/resized to suit a dynamic amoutn of children. Within this bank you could either do a simple approach, of storing a unique "id" number which you then assign to each child when creating them, or you could go a step further and just store the Handle of the object in the bank. Then you could use Object later to dereference a Type handle to the children listed in the bank.
But. Probably the easiest way, as long as you know how many children each parent could have, would be to have an array of types within the Parent type. ie something like this would allow for 3 kids:
Type Parent
Field Name$
Field Children.Child[2]
End Type
Type Child
Field Name$
End Type
Then you can create your objects like this:
Dad.Parent = New Parent
Dad\Name = "Jimmy"
Dad\Children[0] = New Child
Dad\Children[0]\Name = "Kiddo 1"
Dad\Children[1] = New Child
Dad\Children[1]\Name = "Kiddo 2"
Dad\Children[2] = New Child
Dad\Children[2]\Name = "Kiddo 3"
Mom.Parent = New Parent
Mom\Name = "Missus"
Mom\Children[0] = New Child
Mom\Children[0]\Name = "Kiddo 4"
Mom\Children[1] = New Child
Mom\Children[1]\Name = "Kiddo 5"
Mom\Children[2] = New Child
Mom\Children[2]\Name = "Kiddo 6"
etc etc
Then to run through all of the families..
For Folks.Parent = Each Parent
Print "Parent: " + Folks\Name
For counter = 0 to 2
Print "Child: " + Folks\Children[counter]\Name
Next
Next
This is all just off the top off my head, but it should compile.. as you can see it works fairly well, except now you have to know exactly how many children the parents can have. Also, there will be wasted memory if say one parent has 3 kids and another has 5.. Of course you have to allocate your array to support as many children as any of your parents could possibly have. This is the disadvantage. Thats why the bank method I was explaining before would be better, but a bit more complex as well. It would have the advantage of being able to dynamically support as many children as you wanted within each parent, however. (This is a fairly good advantage.) And if you coded around it, you could technically store different handles of different *kinds* of types (whether for example it be a Child type, or even another Parent, or whatever you wanted) But I digress..
Let me know if that helped ;)
One way would be to have an integer field in your parent type, "children" or something, which would contain a handle to a bank. I've suggested a bank because they can be dynamically allocated/resized to suit a dynamic amoutn of children. Within this bank you could either do a simple approach, of storing a unique "id" number which you then assign to each child when creating them, or you could go a step further and just store the Handle of the object in the bank. Then you could use Object later to dereference a Type handle to the children listed in the bank.
But. Probably the easiest way, as long as you know how many children each parent could have, would be to have an array of types within the Parent type. ie something like this would allow for 3 kids:
Type Parent
Field Name$
Field Children.Child[2]
End Type
Type Child
Field Name$
End Type
Then you can create your objects like this:
Dad.Parent = New Parent
Dad\Name = "Jimmy"
Dad\Children[0] = New Child
Dad\Children[0]\Name = "Kiddo 1"
Dad\Children[1] = New Child
Dad\Children[1]\Name = "Kiddo 2"
Dad\Children[2] = New Child
Dad\Children[2]\Name = "Kiddo 3"
Mom.Parent = New Parent
Mom\Name = "Missus"
Mom\Children[0] = New Child
Mom\Children[0]\Name = "Kiddo 4"
Mom\Children[1] = New Child
Mom\Children[1]\Name = "Kiddo 5"
Mom\Children[2] = New Child
Mom\Children[2]\Name = "Kiddo 6"
etc etc
Then to run through all of the families..
For Folks.Parent = Each Parent
Print "Parent: " + Folks\Name
For counter = 0 to 2
Print "Child: " + Folks\Children[counter]\Name
Next
Next
This is all just off the top off my head, but it should compile.. as you can see it works fairly well, except now you have to know exactly how many children the parents can have. Also, there will be wasted memory if say one parent has 3 kids and another has 5.. Of course you have to allocate your array to support as many children as any of your parents could possibly have. This is the disadvantage. Thats why the bank method I was explaining before would be better, but a bit more complex as well. It would have the advantage of being able to dynamically support as many children as you wanted within each parent, however. (This is a fairly good advantage.) And if you coded around it, you could technically store different handles of different *kinds* of types (whether for example it be a Child type, or even another Parent, or whatever you wanted) But I digress..
Let me know if that helped ;)