Simple type question..?

BlitzMax Forums/BlitzMax Beginners Area/Simple type question..?

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.

Type Cow
	Field Name$
	Field Size
	
	Method Moo()
		Print "                                    "+Name$+" Moos"
	EndMethod

EndType

C1:Cow=New Cow
Print "Original object:"
C1.Name="Fat arse"
C1.Size=200
C1.Moo()

C2:Cow=New Cow
CopyType(C1,C2)
Print "New, copied object:"
C2.Moo
Print "New object's name changed to fred"
C2.Name="Fred"
Print "New object:"
C2.Moo
Print "Original object:"
C1.Moo

Function CopyType(Source:Cow,Dest:Cow)
	Local ST:Cow Ptr=Varptr Source, DT:Cow Ptr=Varptr Dest
	Local S:Byte Ptr=Byte Ptr(ST[0]), D:byte Ptr=Byte Ptr(DT[0])
	Local SLeng=SizeOf(Source), DLeng=SizeOf(Dest)
	If SLeng<>DLeng Then Throw "The objects must be the same to copy them."
	For Local i=0 Until SLeng
		D[i]=S[i]
	Next
EndFunction
This works, but I'd rather the copy function was generalized. I can seem to find the Sizeof() an object. yet. SizeOf(o:Object) always returns 0.