Restored from previous forum. Originally posted by freak. I always do it with CopyMemory. A Structure is nothing else than a Block of
allocated Memory, and can be used with all the Memory Commands. The addresses of the
Structured Variables can be found with the '@' in front of them.
Code:
openconsole()
structure test
sa.l
sb.l
endstructure
stra.test
strb.test
stra\sa = 10
stra\sb = 20
; here we copy the contents:
CopyMemory( @stra, @strb, SizeOf( test ) )
; Some Notes:
; The first is the source, the second one the destination Address.
; the 'SizeOf( test )' command returns the Size of the Structure.
; Note that not like some other Languages, you have to use the Name of the
; Structure with SizeOf(), not the name of a Variable.
; (This is also on Fred's list, i think)
;
; The good thing about this way of copying is, if you now change the 'test' Structure, for
; example by adding a new Long Value to it, the CopyMemory() wil automatically copy this one too,
; without any further changes to be made.
printn(str(stra\sa))
printn(str(stra\sb))
printn(str(strb\sa))
printn(str(strb\sb))
Input() ; wait for Enter Key...
That's it...
Timo