Memoryblock size with WriteDouble

Nope. There’s a bug. See this:

That’s by design.

Bug by design? Please read the entire thread.

Please be more specific.

http://documentation.xojo.com/api/files/binarystream.html#binarystream-constructor(mb_as_memoryblock)

A BinaryStream created using a MemoryBlock will automatically re-size the MemoryBlock as needed to contain any additional data written to the stream.

http://documentation.xojo.com/api/files/binarystream.html#binarystream-close

It is critical that you call Close after the back or the size of the MemoryBlock is likely to be wrong.

If you read carefully, we discuss and Lee find and show the bug. Not related to a Stream.

There’s even a FB case.

Interestingly, I can’t replicate it with Xojo 21 R1.1

Ah, I didn’t see that part. My answer about the BinaryStream remains valid, though, and that was the original problem.

(Had you simply pointed that out instead of being condescending about it you could have saved us both some time.)

Well, if you could just read the case I could be taking care of other important things instead of writing summaries to you too. :thinking:

I did read the case. But I started skimming when I got to the part where you wrongly declared a bug in the BinaryStream class. Mea culpa.

Calling bs.close does indeed fix the problem.

Now I’ve got back to run it again the following actually works…

dim mb2 as new memoryblock(9)
mb2.Int8Value(0)=-5
mb2.DoubleValue(1)=100

and mb2 reports 9 bytes.

I literally swear it was wrong earlier… I don’t understand.

Regards,

Lee

Can you point me where you could read such assertive declaration from me? I’m curious about my fail in the communication, that could’ve give you such impression.

In reality it is documented behavior and a valuable feature.

A “maybe” is not a declaration of bug. But a declaration of doubt. But ok. After more investigation from Lee, we got an assertive report that it was occurring WITHOUT the use of streams, just setting values in the memory block was causing an expansion. And THAT I said it was a bug. But my test after that couldn’t confirm it.

Of course. I’m completely off-base. Clearly you didn’t mean to imply that it was a bug. I don’t know what could have led me to believe that.

Maybe you were in a hurry, so it caused the careless reading and demanding summaries. :smile:

I’m tired of this waggery, let’s agree to end here?

OK, moving along, folks. Arguments about who’s right or wrong don’t help solve the issue.

Yes, I was in a hurry. Even so it’s not like I gave bad advice. My response answered the original question and provides useful information about a powerful feature. Writing to memory with a BinaryStream is a neat trick to teach people about. So sue me for being excited about it.

If you read and understood my original response then you got the answers to your earlier questions about the BinaryStream and also learned something new and useful about Xojo. Which was all I wanted.

</waggery>

Not an issue, Lee got confused and made a mistaken report.