Types within types issues

Blitz3D Forums/Blitz3D Beginners Area/Types within types issues

That will leave you with (partly) the same problem as before: you are creating two children, but each time assign them to the same position in the array. One "children" variable (in this case, one position in the array) is just that, a (pointer to a) single children object, and not a collection of children. I mean here:

child(parent\childIndex) = new children
child(parent\childIndex)\name$="Steve/julie"
child(parent\childIndex) = new children
child(parent\childIndex)\name$="Steve/justin"

parent\childIndex will be the same number in both cases (1). So this means child(parent\childIndex) will also be the same position in your array. So if you now try to print the name of Steve's children by accessing that position of the array, what you will find there is a pointer to just the second child, "Justin". Although the first child *has* been created and is somewhere in memory, the array does not contain a pointer to it; this was overwritten by the assignment of the second child to that position.

In principle this big array could be a solution to your problem. Just make the array big enough so you have virtually no limit to the number of children per parent. Although there is still a limit so you would have to check for that. And you would need to solve the above problem; your program should assign each child to a different position of the array, and keep track of which ranges of positions in the array belong to one parent. It is not obvious how to do this, as you say you don't know in advance how many children a parent will have. If you want to use an array, Surreals solution of using one array for every parent (inside the parent type) seems better than using one big array that is shared by all parents. In both cases you have to make the arrays big enough in advance.