Appending to a MemoryBlock

Is it possible to append one MemoryBlock to another?

I see that there is an Append method for the Xojo.Core.MutableMemoryBlock but I am using the classic MemoryBlock. For example, could I append a Double to the end of an existing MemoryBlock?

You have to do it manually. Change the size of the first, then use StringValue (or whatever is appropriate) to grab the value from the second.

I’ve just been playing around with this. It looks like Operator_Add has been been overridden for MemoryBlocks so it’s as easy as this:

[code]Dim mb1 As MemoryBlock = “Hi” // Bytes are: 72, 105
Dim mb2 As New MemoryBlock(8)
mb2.DoubleValue(0) = 42.5 // Bytes are: 0, 0, 0, 0, 0, 64, 69, 64

mb1 = mb1 + mb2
// mb1 bytes are now: 72, 105, 0, 0, 0, 0, 0, 64, 69, 64[/code]

Guess I shouldn’t have been over-thinking it…

indeed yet it appears to be undocumented Page Not Found — Xojo documentation
There are

Operator_Add(value As MemoryBlock) As MemoryBlock
Operator_Compare(value As MemoryBlock) As Integer

as well as the convert to and from Ptr and String


Good to know, especially since I’ll be giving a talk on this at XDC.