MemoryBlock
Class MemoryBlock

Method PrototypeDescription
Function BooleanValue( offset As Integer ) As Booleaninterpret a byte as true (nonzero) or false (0)
Sub BooleanValue( offset As Integer, Assigns newValue As Boolean )set a byte as true (1) or false (0)

Function Byte( offset As Integer ) As Integerget a byte as a value 0-255 (same as UInt8Value)
Sub Byte( offset As Integer, Assigns newValue As Integer )set a byte as a value 0-255 (same as UInt8Value)

Function ColorValue( offset As Integer, bits As Integer ) As Colorget a 16, 24, or 32-bit color
Sub ColorValue( offset As Integer, bits As Integer, Assigns newValue As Color )set a 16, 24, or 32-bit color

Sub Constructor( size As Integer )initialize to the given number of bytes

Function CString( offset As Integer ) As Stringreturn the null-terminated string starting at offset
Sub CString( offset As Integer, Assigns newValue As String )store the given string, followed by a null

Function CurrencyValue( offset As Integer ) As Currencyget a 4-byte currency value
Sub CurrencyValue( offset As Integer, Assigns newValue As Currency )set a 4-byte currency value

Function DoubleValue( offset As Integer ) As Doubleget an 8-byte floating-point value
Sub DoubleValue( offset As Integer, Assigns newValue As Double )set an 8-byte floating-point value

Function Int16Value( offset As Integer ) As Int16get a 2-byte signed integer
Sub Int16Value( offset As Integer, Assigns newValue As Int16 )set a 2-byte signed integer

Function Int32Value( offset As Integer ) As Int32get a 4-byte signed integer
Sub Int32Value( offset As Integer, Assigns newValue As Int32 )set a 4-byte signed integer
Function Int64Value( offset As Integer ) As Int64get an 8-byte signed integer
Sub Int64Value( offset As Integer, Assigns newValue As Int64 )set an 8-byte signed integer

Function Int8Value( offset As Integer ) As Int8get a 1-byte signed integer
Sub Int8Value( offset As Integer, Assigns newValue As Int8 )set a 1-byte signed integer

Function LeftB( bytes As Integer ) As MemoryBlockget a new MemoryBlock copying the leftmost portion of this one

Function LittleEndian() As Booleanget whether integers and colors are interpreted in little-endian format
Sub LittleEndian ( Assigns newValue As Boolean )set whether integers and colors are interpreted in little-endian format

Function Long( offset As Integer ) As Integersame as Int32Value
Sub Long( offset As Integer, Assigns newValue As Integer )same as Int32Value

Function MidB( offset As Integer, length As Integer = 0 ) As Integerget a new MemoryBlock copying the given portion of this one

Function PString( offset As Integer ) As Stringget a Pascal (length-prefixed) string at the given location
Sub PString( offset As Integer, Assigns newValue As String )store a length byte followed by the text of the given string

Function RightB( bytes As Integer ) As Integerget a new MemoryBlock copying the rightmost portion of this one

Function Short( offset As Integer ) As Integersame as Int16Value
Sub Short( offset As Integer, Assigns newValue As Integer )same as Int16Value

Function SingleValue( offset As Integer ) As Doubleget a 4-byte floating-point value
Sub SingleValue( offset As Integer, Assigns newValue As Double )set a 4-byte floating-point value

Sub Size ( Assigns newValue As Integer )get the number of bytes in this MemoryBlock
Function Size() As Integerset the number of bytes in this MemoryBlock, truncating or expanding as needed

Function StringValue( offset As Integer, length As Integer ) As Stringget a string of bytes
Sub StringValue( offset As Integer, length As Integer, Assigns newValue As String )store a string of bytes

Function UInt16Value( offset As Integer ) As UInt16get a 2-byte unsigned integer
Sub UInt16Value( offset As Integer, Assigns newValue As UInt16 )set a 2-byte unsigned integer

Function UInt32Value( offset As Integer ) As UInt32get a 4-byte unsigned integer
Sub UInt32Value( offset As Integer, Assigns newValue As UInt32 )set a 4-byte unsigned integer

Function UInt64Value( offset As Integer ) As UInt64get an 8-byte unsigned integer
Sub UInt64Value( offset As Integer, Assigns newValue As UInt64 )set an 8-byte unsigned integer

Function UInt8Value( offset As Integer ) As UInt8get a 1-byte unsigned integer
Sub UInt8Value( offset As Integer, Assigns newValue As UInt8 )set a 1-byte unsigned integer

Function UShort( offset As Integer ) As Integersame as UInt16Value
Sub UShort( offset As Integer, Assigns newValue As Integer )same as UInt16Value

Function WString( offset As Integer ) As Stringget a null-terminated UTF-16 string
Sub WString( offset As Integer, Assigns newValue As String )store a null-terminated UTF-16 string


The MemoryBlock class represents a chunk of memory, and provides accessors to store and retrieve binary data within that chunk in a variety of ways.

MemoryBlocks can be resized (by assigning to Size), and their contents will be preserved (as much as will fit in the new size). A new MemoryBlock, or the extra space allocated when the size is increased, is initialized to all null (zero) bytes.