Dynamic Resizing

BlitzMax Forums/BlitzMax Beginners Area/Dynamic Resizing

This may be the thing you are looking for:
Type ObjectData
	Field indexdata:indices[0]
End Type

Type Indices
	Field indices:Int[0]
End Type

' Create a new object of type ObjectData
Local objectpointer:ObjectData = New ObjectData

' Resize the array "indexdata" to let it have 10 indexes (0..9)
objectpointer.indexdata = objectpointer.indexdata[..10]

' Create a new "indices" object at index 1 of the array "indexdata"
objectpointer.indexdata[1] = New indices
' Resize the array "indices" inside the indices type-instance, inside "indexdata" array index 1
objectpointer.indexdata[1].indices = objectpointer.indexdata[1].indices[..5]
' Set a random value from 1 to 100 inside the indices array at index 2, which resides inside the "indexdata"
' array at index 1
objectpointer.indexdata[1].indices[2] = Rand(1, 100)

' Now at index 1 of array "indexdata", there's an array with 5 indexes (0..4)



' Create a new "indices" object at index 2 of the array "indexdata"
objectpointer.indexdata[2] = New indices
' Resize the array "indices" inside the indices type-instance, inside "indexdata" array index 1
objectpointer.indexdata[2].indices = objectpointer.indexdata[1].indices[..20]
' Set a random value from 1 to 100 inside the indices array at index 12, which resides inside the "indexdata"
' array at index 1
objectpointer.indexdata[2].indices[12] = Rand(1, 100)

' Now at index 2 of array "indexdata", there's an array with 20 indexes (0.19)



PrintData(objectpointer, 1, 2)
PrintData(objectpointer, 2, 12)

Function PrintData(a:ObjectData, x, y)
	Print a.indexdata[x].indices[y]
End Function