Passing subtypes as Function parameters

Blitz3D Forums/Blitz3D Programming/Passing subtypes as Function parameters

If you attempted to Create_Joint(objects(n)\joint) after the For...Next, n=11 therefor it is Null. You should try calling the function within the For...Next.

Type vector
	Field x#
	Field y#
	Field z#	
End Type

Type joint
   Field pos.vector
   Field joint_type
End Type

Type obj
   Field pos.vector
   Field size
   Field joint.joint
End Type

Dim objects.obj(10)

For n=0 To 10
   objects(n)=New obj
   objects(n)\pos.vector=New vector
   objects(n)\joint.joint=New joint
   objects(n)\joint\joint_type=n ;<-- a lil test
   objects(n)\joint\pos.vector=New vector
   Create_Joint(objects(n)\joint)
Next

WaitKey()

Function Create_Joint(j.joint)
      Print "jointtype="+j\joint_type
End Function