Number of instances of a type

Blitz3D Forums/Blitz3D Beginners Area/Number of instances of a type

You can use a function for counting all Things:
Type Thing
	Field Name$
End Type

SeedRnd MilliSecs()

; Create a random number of Thing's
For i = 1 To Rand(10,100)
	temppointer.Thing = New Thing

Next

Print CountThings()
WaitKey()
End



Function CountThings()
	Local Count

	; Loop through all Thing's and count them
	For temppointer.Thing = Each Thing
		Count = Count + 1
	Next

	Return Count
End Function