Banks

BlitzMax Forums/BlitzMax Beginners Area/Banks

Crovean(Posted 2010) [#1]
I'm trying to figure what banks are and what they are good for.. The documents doesn't give me much. Can someone give me a brief explanation please? ...and how do I know how to set the size of a bank?


Brucey(Posted 2010) [#2]
Banks are simply blocks of memory. It can represent any kind of data.
You might use it for some custom data, or to store image data. Anything really. The also support TStream, so you can use them for stream data into or out of memory.

There's a section in the documentation (Modules -> Miscellaneous -> Banks) which shows the available API.


Crovean(Posted 2010) [#3]
I read the documentation, but didn't understand much... :-) I'll take a look in the archives for some good examples :-)


ImaginaryHuman(Posted 2010) [#4]
Like Brucey said they're a bank of memory to use for whatever you like. It's a bit of a more convenient way of using memory without having to do things like `memalloc()`, to keep track of allocated blocks, to deallocate properly, etc.. using a bank it's handled by the garbage collector more easily and you get supporting functions like PeekByte, PokeInt etc.

If you know what you're doing you can of course do the same simpler and faster yourself using arrays/memalloc and pointers. Even if I use a bank I usually get the pointer and then use pointers for access.

You might use a bank to load a binary file, some data from disk, you might use it as input/output to the Compress() and Compress2() commands, you might use it to store some kind of special format of data in one place rather than in a custom type with fields, etc.