Android Question How to clone CSBuilder data

toby

Well-Known Member
Licensed User
Longtime User
What I expect: to clone a copy of csb1 data to csb2 and csb1 should remain unchanged regardless of whatever I change to csb2.
What I've got so far: csb1 and csb2 are the same.

Could someone show me how to achieve what I want, please?

B4X:
Dim csb1 As CSBuilder
    csb1.Initialize
    csb1.color(xui.color_blue).Append("Tigers are big. ").pop
    Dim csb2 As CSBuilder=csb1 'get a copy of csb1
    csb2.Append("  They live in the wild.")
    'The output of following two lines are identical: Tigers are big.   They live in the wild.
    Log(csb1) 'it should output: Tigers are big.
    Log(csb2)

TIA
 
Last edited:
Solution
My solution: Use Append as shown in the code
B4X:
    Dim csb1 As CSBuilder
    csb1.Initialize
    csb1.Color(xui.Color_Blue).Append("Tigers are big. ").PopAll
    Dim csb2 As CSBuilder
    csb2.Initialize.Append(csb1).Append("  They live in the wild.")
    Log(csb2) 'output: Tigers are big.   They live in the wild.
    Log(csb1) 'output: Tigers are big.

toby

Well-Known Member
Licensed User
Longtime User
My solution: Use Append as shown in the code
B4X:
    Dim csb1 As CSBuilder
    csb1.Initialize
    csb1.Color(xui.Color_Blue).Append("Tigers are big. ").PopAll
    Dim csb2 As CSBuilder
    csb2.Initialize.Append(csb1).Append("  They live in the wild.")
    Log(csb2) 'output: Tigers are big.   They live in the wild.
    Log(csb1) 'output: Tigers are big.
 
Upvote 0
Solution
Top