Dynamic Resizing

BlitzMax Forums/BlitzMax Beginners Area/Dynamic Resizing

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.

And with this :
Type toto
	Field index:Int[][]

	Method Init(val:Int, val1:Int)
		index=index[..val+1]
		index[val]=index[val][..val1]
	End Method
End Type

' We create a new type toto
ex:toto=New toto
' We initialize first array to 0 (1 index) and second array to 0-2 (3 index)
ex.Init(0,3)
' We assign the 3 values to array [0] because there is space for 3 values in the second array
ex.index[0]=[1,2,3]  ' Assign 3 values to the first array index 0
' Print result
Print ex.index[0][0]
Print ex.index[0][1]
Print ex.index[0][2]
Print

' Now we need 5 values in the second array.
' We resize this array.
ex.Init(0,5)
' We assign value 4 and 5 (you need to assign new value one by one)
ex.index[0][3]=4 ; ex.index[0][4]=5
' Print result
Print ex.index[0][0]
Print ex.index[0][1]
Print ex.index[0][2]
Print ex.index[0][3]
Print ex.index[0][4]


You need to index the first array before init the second array.
Array[][] indicate array is created but not sized, return an error.
You can do this :
First assign an array [0][] or
First assign an array [2][] or
First assign an array [0][10] or First assign an array [2][10]
No importance since the first array is initialized.

More compact, no pointer.