PureBasic v4.40b7 now supports a simple way to copy structures with
Code: Select all
this.test = that.test ;works great
Code: Select all
*this.test = *that.test ;doesn't work for copying structure's contents
The simple code below copies the 'test' structure via pointers by using the 'work' structure so that the structure will be dereferenced for copying:
Code: Select all
;original structure
Structure test
index.i
phrase.s
EndStructure
;work structure for copying
Structure work
test.test[0]
EndStructure
Procedure copyByPtr(*a.work,*b.work)
*b\test = *a\test
EndProcedure
Define V1.test, V2.test
V1\index = 5
V1\phrase = "hello"
Debug "----source----"
Debug V1\index
Debug V1\phrase
Debug "----destination contents before----"
Debug V2\index
Debug V2\phrase
copyByPtr(@V1,@V2)
Debug "----destination contents after----"
Debug V2\index
Debug V2\phrase
