Banks
A bank object encapsulates a block of memory you can use to store arbitrary data.
Banks are useful for storing data that is of no fixed type - for example, the contents of a binary file.
To create a bank, use the CreateBank command.
To write data to a bank, use one of the Poke commands. To read data from a bank, use one of the Peek commands.
In addition, banks can be loaded or saved using LoadBank or SaveBank.
Functions
Function BankBuf:Byte Ptr( bank:TBank ) |
Returns | A byte pointer to the bank's internal memory buffer. |
Description | Get bank's memory buffer. |
Information | Please use LockBank and UnlockBank instead of this method. |
Function BankCapacity( bank:TBank ) |
Returns | The capacity, in bytes, of the bank's internal memory buffer. |
Description | Get capacity of bank. |
Information | The capacity of a bank is the size limit before a bank must allocate
more memory due to a resize. Bank capacity may be increased due to a call
to ResizeBank by either 50% or the requested amount, whichever is greater.
Capacity never decreases. |
Function BankSize( bank:TBank ) |
Returns | The size, in bytes, of the bank's internal memory buffer. |
Description | Get size of bank. |
Function CopyBank( src_bank:TBank,src_offset,dst_bank:TBank,dst_offset,count ) |
Description | Copy bank contents. |
Information | CopyBank copies count bytes from src_offset in src_bank to dst_offset
in dst_bank. |
Function CreateBank:TBank( size=0 ) |
Returns | A bank object with an initial size of size bytes. |
Description | Create a bank. |
Information | CreateBank creates a Bank allocating a specified amount of memory that
can be used for storage of binary data using the various Poke and
Peek commands. |
Function CreateStaticBank:TBank( buf:Byte Ptr,size ) |
Returns | A bank object that references an existing block of memory. |
Description | Create a bank with existing data. |
Information | The memory referenced by a static bank is not released when the bank is deleted.
A static bank cannot be resized. |
Function LoadBank:TBank( url:Object ) |
Returns | A bank containing the binary contents of url, or null if url could not be opened. |
Description | Load a bank. |
Information | LoadBank reads the entire contents of a binary file from a specified url into a newly
created bank with a size matching that of the file. |
Function LockBank:Byte Ptr( bank:TBank ) |
Returns | A byte pointer to the memory block controlled by the bank. |
Description | Lock a bank's memory block. |
Information | While locked, a bank cannot be resized.
After you have finished with a bank's memory block, you must use Unlock
to return it to the bank. |
Function PeekByte( bank:TBank,offset ) |
Returns | The byte value at the specified byte offset within the bank. |
Description | Peek a byte from a bank. |
Information | A byte is an unsigned 8 bit value with a range of 0..255. |
Function PeekDouble!( bank:TBank,offset ) |
Returns | The double value at the specified byte offset within the bank. |
Description | Peek a double from a bank. |
Information | A double requires 8 bytes of storage. |
Function PeekFloat#( bank:TBank,offset ) |
Returns | The float value at the specified byte offset within the bank. |
Description | Peek a float from a bank. |
Information | A float requires 4 bytes of storage. |
Function PeekInt( bank:TBank,offset ) |
Returns | The int value at the specified byte offset within the bank. |
Description | Peek an int from a bank. |
Information | An int is a signed 32 bit value (4 bytes). |
Function PeekLong:Long( bank:TBank,offset ) |
Returns | The long integer value at the specified byte offset within the bank. |
Description | Peek a long integer from a bank. |
Information | A long is a 64 bit integer that requires 8 bytes of memory. |
Function PeekShort( bank:TBank,offset ) |
Returns | The short value at the specified byte offset within the bank. |
Description | Peek a short from a bank. |
Information | A short is an unsigned 16 bit (2 bytes) value with a range of 0..65535. |
Function PokeByte( bank:TBank,offset,value ) |
Description | Poke a byte into a bank. |
Function PokeDouble( bank:TBank,offset,value! ) |
Description | Poke a double into a bank. |
Information | A double requires 8 bytes of storage. |
Function PokeFloat( bank:TBank,offset,value# ) |
Description | Poke a float into a bank. |
Information | A float requires 4 bytes of storage. |
Function PokeInt( bank:TBank,offset,value ) |
Description | Poke an int into a bank. |
Information | An int is a signed 32 bit value that requires 4 bytes of storage. |
Function PokeLong( bank:TBank,offset,value:Long ) |
Description | Poke a long integer int into a bank. |
Information | A long is a 64 bit integer that requires 8 bytes of storage. |
Function PokeShort( bank:TBank,offset,value ) |
Description | Poke a short into a bank. |
Information | An short is an unsigned 16 bit value that requires 2 bytes of storage. |
Function ReadBank( bank:TBank,stream:TStream,offset,count ) |
Returns | The number of bytes successfully read from the Stream. |
Description | Read bytes from a Stream to a Bank. |
Function ResizeBank( bank:TBank,size ) |
Description | Resize a bank. |
Information | ResizeBank modifies the size limit of a bank. This may cause memory to be
allocated if the requested size is greater than the bank's current capacity,
see BankCapacity for more information. |
Function SaveBank( bank:TBank,url:Object ) |
Returns | True if successful. |
Description | Save a bank. |
Information | SaveBank writes it's entire contents to a url. If the url is a file path a new
file is created. |
Function UnlockBank( bank:TBank ) |
Description | Unlock a bank's memory block. |
Information | After you have finished with a bank's memory block, you must use Unlock
to return it to the bank. |
Function WriteBank( bank:TBank,stream:TStream,offset,count ) |
Returns | The number of bytes successfully written to the Stream. |
Description | Write bytes from a Bank to a Stream. |
Types
Type TBank Extends TData |
Description | Memory bank. |
Method Buf:Byte Ptr() |
Returns | A byte pointer to the memory block controlled by the bank. |
Description | Get a bank's memory pointer. |
Information | Please use Lock and Unlock instead of this method. |
Method Capacity() |
Returns | The capacity, in bytes, of the bank's internal memory buffer. |
Description | Get capacity of bank. |
Method Lock:Byte Ptr() |
Returns | A byte pointer to the memory block controlled by the bank. |
Description | Lock a bank's memory block. |
Information | While locked, a bank cannot be resized.
After you have finished with a bank's memory block, you must use Unlock
to return it to the bank. |
Method PeekByte( offset ) |
Returns | The byte value at the specified byte offset within the bank. |
Description | Peek a byte from a bank. |
Method PeekDouble!( offset ) |
Returns | The double value at the specified byte offset within the bank. |
Description | Peek a double from a bank. |
Method PeekFloat#( offset ) |
Returns | The float value at the specified byte offset within the bank. |
Description | Peek a float from a bank. |
Method PeekInt( offset ) |
Returns | The int value at the specified byte offset within the bank. |
Description | Peek an int from a bank. |
Method PeekLong:Long( offset ) |
Returns | The long value at the specified byte offset within the bank. |
Description | Peek a long from a bank. |
Method PeekShort( offset ) |
Returns | The short value at the specified byte offset within the bank. |
Description | Peek a short from a bank. |
Method PokeByte( offset,value ) |
Description | Poke a byte into a bank. |
Method PokeDouble( offset,value! ) |
Description | Poke a double value into a bank. |
Method PokeFloat( offset,value# ) |
Description | Poke a float value into a bank. |
Method PokeInt( offset,value ) |
Description | Poke an int into a bank. |
Method PokeLong( offset,value:Long ) |
Description | Poke a long value into a bank. |
Method PokeShort( offset,value ) |
Description | Poke a short into a bank. |
Method Read( stream:TStream,offset,count ) |
Description | Read bytes from a stream into a bank. |
Method Resize( size ) |
Description | Resize a bank. |
Method Save( url:Object ) |
Description | Save a bank to a stream. |
Information | Return True if successful, otherwise False. |
Method Size() |
Returns | The size, in bytes, of the memory block controlled by the bank. |
Description | Get a bank's size. |
Method Unlock() |
Description | Unlock a bank's memory pointer. |
Information | After you have finished with a bank's memory block, you must use Unlock
to return it to the bank. |
Method Write( stream:TStream,offset,count ) |
Description | Write bytes in a bank to a stream. |
Function Create:TBank( size ) |
Returns | A new TBank object with an initial size of size. |
Description | Create a bank. |
Function CreateStatic:TBank( buf:Byte Ptr,size ) |
Description | Create a bank from an existing block of memory. |
Function Load:TBank( url:Object ) |
Returns | A new TBank object. |
Description | Load a bank from a stream. |
Information | Returns a new TBank object if successfull, otherwise Null. |
Module Information
Version | 1.06 |
Author | Mark Sibly |
License | Blitz Shared Source Code |
Copyright | Blitz Research Ltd |
Modserver | BRL |
History | 1.06 Release |
History | Added Lock/Unlock to replace Buf |
History | 1.05 Release |
History | Fixed Read/Write using ReadBytes/WriteBytes |