View Single Post
Old 26 March 2015, 22:04   #4
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by idrougge View Post
Thanks, I solved it using some inline assembler, but it's nice to see that there is a system call for doing it as well. And as usual, Blitz's online help is of no help – according to it, CopyMem_ takes arguments in parentheses. Your example is correct – no parens.

I was hoping there was a simpler way than actually copying memory, though.
CopyMem_ is a systemcall. Please make sure you add proper checks if you going to use it.

The solution depends on what you want:
Do you really want to COPY the type? If not, you could (but must not!) try to bend a pointer temporarily to the src address:

Code:
Newtype.foo
   a.w
   b.w
   c.w 
End Newtype

Deftype.foo   tsrc

tsrc\a=10,20,30       ;put in some values

*tdst.foo = tsrc      ;"clone" the struct by taking over the address

if *tdst
  NPrint *tdst        ;should be = &tsrc

  NPrint *tdst\a
  NPrint *tdst\b
  NPrint *tdst\c
;
*tdst=0               ;make sure we are not trying to free that later (GURU)
endif

MouseWait
End
Cylon is offline  
 
Page generated in 0.04236 seconds with 11 queries