OPEN MEMORY

Stream = [ OPEN ] MEMORY Pointer [ FOR [ READ ] [ WRITE ] ]

Create a stream that allows to directly read binary data from memory, or write binary data to memory.

  • If the READ keyword is specified, then reading is allowed. This keyword is optional, as reading is actually always allowed.

  • If the WRITE keyword is specified, then writing is allowed.

The first read or write is done at the memory address specified by Pointer, but beware that reading or writing to the stream makes the stream internal pointer go forward.

The stream position set by SEEK or returned by Seek is the number of bytes from Pointer.

If you try to write to a forbidden memory address, you will get an error. The interpreter won't crash.

IMPORTANT!

Reading or writing a string on a memory stream with the READ or WRITE instructions does not use the Gambas Binary Data Representation.

Instead, null-terminated strings are read or written.

Since 3.5

The OPEN MEMORY syntax is available since Gambas 3.5.

See also