Passing a type in a function.

Blitz3D Forums/Blitz3D Beginners Area/Passing a type in a function.

Not too sure if this is what you mean, but this passes Rocket objects to a function that then lists the fields of the object passed -- could easily be redirected to a file instead...


; The type...

Type Rocket
	Field x
	Field y
	Field fuel
End Type



; Create 10 rockets...

For a = 1 To 10
	r.Rocket = New Rocket
	r\x = Rand (0, 639)
	r\y = Rand (0, 479)
	r\fuel = Rand (0, 100)
Next

; Call function to print out field info...

For r.Rocket = Each Rocket
	counter = counter + 1
	Print "Info for rocket " + counter + ":"
	Print ""
	PrintRocketFields (r)
	Print ""
Next




; The function...

Function PrintRocketFields (passed.Rocket)
	Print passed\x
	Print passed\y
	Print passed\fuel
End Function