Android Question copy rect

Rudi_

Member
Licensed User
Longtime User
i have to temporarily store the properties of an rect, so i write TempRect = ARect, in this case TempRect stores a reference of ARect, when the data of ARect changes, the data of TempRect also changes, but i need a seperate copy that is not affected from the source. Is the only way to copy each of the items manually ?
 

Xandoca

Active Member
Licensed User
Longtime User
Please, try using this code. It's not working in my tests, maybe work for you.
B4X:
Sub CopyObject(Obj As Object) As Object
  Dim raf As RandomAccessFile
  Dim n=256 As Int
  Dim notdone=True As Boolean
  Do While notdone
      notdone=False
      Dim buffer(n) As Byte
      Try
        raf.Initialize3(buffer,False)
        raf.WriteObject(Obj, True, 0)
      Catch
        n=n*10
        notdone=True
      End Try
      If notdone=False Then
        Dim newObj As Object
        newObj = raf.ReadObject(0)
      End If
      raf.Close
  Loop
  Return newObj
End Sub
 
Upvote 0
Top