An array of a user defined type with a constructor

BlitzMax Forums/BlitzMax Beginners Area/An array of a user defined type with a constructor

How about a Function to create the array for you.

Type TTest
	Field x:Int
        'return an array of types
	Function CreateTTestArray:TTest[]( count, x:Int )
		local ar:TTest[count]
		for local a=0 until count
			ar[a]=TTest.Create(x)
		next
		return ar
	endfunction
	Function Create:TTest(x:Int)
		Test:TTest=New TTest
		Test.x=x
		Return Test
	End Function
End Type

'Call function to create an array.
local n:TTest[] = TTest.CreateTTestArray(20, 3)

print n[10].x