How clone objects?

BlitzMax Forums/BlitzMax Programming/How clone objects?

orgos(Posted 2009) [#1]
Hello people.

How i can clone objects in BMax?

Having:

Type myObject
Field name:String
Field x:Int
Field y:Int
End Type

Local a:myObject
a.name = "temp"
a.x = 10
a.y = 10

Local b:myObject

I want to clone a on b.

Any solution?

thanks.


Azathoth(Posted 2009) [#2]
Either create a clone function for each type, or use reflection like this


therevills(Posted 2009) [#3]
I had the same problem in this thread:

http://www.blitzbasic.co.nz/Community/posts.php?topic=82368

And I ended up using Azathoth's code ;-)

BTW Thank you Azathoth for sharing it :)


orgos(Posted 2009) [#4]
Ok I resolve the problem using some code of Azathoth's solution. Thanks