How to convert from byte ptr to type instance ?

BlitzMax Forums/BlitzMax Programming/How to convert from byte ptr to type instance ?

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.

there is a simple workaround if you know the size of the original object:

Type mytype
	Field val:Int
End Type

Local m:mytype,k:mytype
Local convert:Byte Ptr
Local size:Int

m = New mytype
m.val = 10
convert = m
size = SizeOf(m)

MemCopy (Byte Ptr(k),convert,size)


Print k.val

Delay 2000


PS: I use this to copy type instances :)