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.

Function reference

CreateBank:TBank( size=0 )   Create a bank

Returns: A bank object with an initial size of size


CreateStaticBank:TBank( buf:Byte Ptr,size )   Create a bank with existing data

Returns: A bank object that references an existing block of memory

The memory referenced by a static bank is not released when the bank is deleted. A static bank cannot be resized.


LoadBank:TBank( url:Object )   Load a bank

Returns: A bank containing the binary contents of url, or null if url could not be opened


SaveBank( bank:TBank,url:Object )   Save a bank

Returns: True if successful.


BankBuf:Byte Ptr( bank:TBank )   Get bank's memory buffer

Returns: A byte pointer to the bank's internal memory buffer


BankSize( bank:TBank )   Get size of bank

Returns: The size, in bytes, of the bank's internal memory buffer


BankCapacity( bank:TBank )   Get capacity of bank

Returns: The capacity, in bytes, of the bank's internal memory buffer


ResizeBank( bank:TBank,size )   Resize a bank

CopyBank( src_bank:TBank,src_offset,dst_bank:TBank,dst_offset,count )   Copy bank contents

PeekByte( bank:TBank,offset )   Peek a byte from a bank

Returns: The byte value at the specified byte offset within the bank


PokeByte( bank:TBank,offset,value )   Poke a byte into a bank

PeekShort( bank:TBank,offset )   Peek a short from a bank

Returns: The short value at the specified byte offset within the bank


PokeShort( bank:TBank,offset,value )   Poke a short into a bank

PeekInt( bank:TBank,offset )   Peek an int from a bank

Returns: The int value at the specified byte offset within the bank


PokeInt( bank:TBank,offset,value )   Poke an int into a bank

PeekLong:Long( bank:TBank,offset )   Peek a long integer from a bank

Returns: The int value at the specified byte offset within the bank


PokeLong( bank:TBank,offset,value:Long )   Poke a long integer int into a bank

PeekFloat#( bank:TBank,offset )   Peek a float from a bank

Returns: The float value at the specified byte offset within the bank


PokeFloat( bank:TBank,offset,value# )   Poke a float into a bank

PeekDouble!( bank:TBank,offset )   Peek a double from a bank

Returns: The double value at the specified byte offset within the bank


PokeDouble( bank:TBank,offset,value! )   Poke a double into a bank

ReadBank( bank:TBank,stream:TStream,offset,count )   Read bytes from a Stream to a Bank

Returns: The number of bytes successfully read from the Stream


WriteBank( bank:TBank,stream:TStream,offset,count )   Write bytes from a Bank to a Stream

Returns: The number of bytes successfully written from the Stream


Module Information

Modulebrl.bank
Version 1.00
Author Mark Sibly
License Blitz Shared Source Code
Copyright Blitz Research Ltd
Modserver BRL