How to save an array?
Blitz3D Forums/Blitz3D Programming/How to save an array?
| ||
Hi, I'm a recent convert from Dark Basic and I'm still getting used to some of the nuances of Blitz (although it's been much easier to pick up than I thought it would be). I'm wondering what sort of method you would use to save the contents of an array and then load them back in, like the Load Array / Save Array commands from DB? Thanks! |
| ||
AFIAK you have to loop the array and save each element, maybe someone that knows more BB can correct me :) |
| ||
ZombieWoof is correct. Here is how I would save/load an integer array. Sadly you cannot pass an array as a function :/ Dim MyArray(100) file=WriteFile("MyArray.dat") For a=0 to 100 WriteInt file,MyArray(a) Next CloseFile file file=OpenFile("MyArray.dat") For a=0 to 100 MyArray(a)=ReadInt(file) Next CloseFile file I wrote this in browser so it might be buggy |
| ||
Okay, thanks. I didn't want to go creating a function to do that if there was a simpler way. No big deal, though :) Thanks! |