XOJO 2019 r3.2 - Windows Desktop
How could I use ‘Xojo.Core.MutableMemoryBlock’ for concatenating two memoryblocks.
I have two memory blocks ‘mb’ and ‘mbChunks’ .
I would like to create a new memoryblock ‘mbNew’ where ‘mb’ is the first part and ‘mbChunks’ is added at the end of ‘mb’.
var mbNew as new Xojo.Core.MutableMemoryBlock( mb.Size + mbChunks.Size )
mbNew.Left( mb.Size ) = mb
mbNew.Mid( mb.Size, mbChunks.Size ) = mbChunks
If you use normal MemoryBlocks and MBS Xojo Plugins, you can call JoinDataMBS function to join an array of MemoryBlocks to one big MemoryBlock efficiently.
JoinDataMBS can also join an array of Variant, where you may have mixed MemoryBlocks and Strings to join.
Thanks both for the replies.
The code with the ‘Xojo.Core.MutableMemoryBlock’ did not work for me. I probably do something wrong.
I also try to create my new project in Xojo 2019r3.2 or later without any plugin for now.
I found a solution in another topic on this great forum ;
mb1 and mb2 are the two memoryblocks to put together
Var joinedMb As New MemoryBlock(mb1.Size + mb2.Size)
joinedMb.StringValue(0, mb1.Size) = mb1.StringValue(0, mb1.Size)
joinedMb.StringValue(mb1.Size, mb2.Size) = mb2.StringValue(0, mb2.Size)