Bank commands vs file commands

Blitz3D Forums/Blitz3D Beginners Area/Bank commands vs file commands

fox95871(Posted 2009) [#1]
Just a quick question about the difference between the bank commands and the file commands as far as which I can use for my engine, and which I can avoid. What I want to do is have character positions, level shapes, etc., be saved to a text file whenever they're changed by the user. It seems like all I need to do that is the file and file stream commands, but the bank commands look so similar it's a little confusing.

Can I just forget banks and use read and write like a normal person? I don't care much for the lower level stuff when it seems like the whole point of Blitz is to take care of that stuff for you so you don't have to.


Gabriel(Posted 2009) [#2]
I don't see how they're similar really. They do completely different things. One is for storing and retrieving data in files, one is for storing and retrieving data in memory. Ok, I guess they're both for storing and retrieving data, but I don't really see any crossover, since you either need to store in memory or file or both.


fox95871(Posted 2009) [#3]
Just from a general perspective I guess, PokeInt, PeekInt, WriteInt, ReadInt...you know. Well I guess if that's not true then, what advantages are there to using banks? Are they really so great that I should definitely use them? Like I said, it's just pretty simple variable changes really, but they do need to be saved to an outside file. If I never have to touch a custom memory bank in order to do that I'd be happy. But is it somehow faster to do both, or can I just rely on Blitz's internal handling of memory I guess is what I'm asking.


Ross C(Posted 2009) [#4]
Personally, unless your doing a hell of alot of calculations where your constantly accessing values, or you need to make the best use of space (each int in an array is 32 bits, where as poke byte is only 8 bits, i don't think there is too much of a speed difference.

I find arrays easier to use.


Zethrax(Posted 2009) [#5]
As Ross said, banks are mainly useful where you need to manipulate data in RAM at the byte and bit level. If you need to save your data to a file on disk, and that data needs to be structured at the byte and bit level, then it can be useful to use banks to organize the data before saving it.


fox95871(Posted 2009) [#6]
Thanks. I think I'll just stick with the file commands then.


jfk EO-11110(Posted 2009) [#7]
It's also very useful to read an entire file to a bank using readbytes, then edit some things, eg. replace a certain string, and then write it back to the harddrive, using Writebytes. This is much faster than reading and writing a sequence of values to/from a file one by one.