mutableMemoryBlock.append example

Does anybody have a quick example how to use this. I thought it would be pretty simple, such as:

dim returnContent as xojo.core.mutableMemoryBlock


However, nope… I get a ‘There is more than one item with this name and it’s not clear which this refers…’ bug notification.

The Append method takes a MemoryBlock or an array of Bytes. Just 255 is neither.

Perhaps this:

[code]Dim bytes() As Byte

Dim returnContent As Xojo.Core.MutableMemoryBlock

Ah, very good. Thanks, Paul.

I have a byte() array that consists of two bytes (verified by printing the uBound, which is 1); however, when I append it to a fresh mutableMemoryBlock… the size of that becomes 3, with mutableMemoryBlock.uInt8Value(0) = 0 every time. Is this expected?

Doesn’t sound like what I’d expect. Please file a bug report.

This didn’t appear to be a bug after-all, my apologies. You have to define the space used with the mutableMemoryBlock first, such as:

returnContent = new mutableMemoryBlock(2)

I was constructing it with one byte bigger than the byte() array size. Since I was appending the data, it only make common-sense (which I was obviously lacking at the time) that the first byte in the memoryBlock was 0.

If somebody could cancel 39206 - mutableMemoryBlock.append adds null value when appending bytes(), that’d be great. Sorry for the inconvenience.