I've been putting together an editor of sorts to go with my game. That way we can tweak the game settings for better gameplay and save it as a "DefaultSettings" file.
if keystate(DIK_S)=1
make memblock from array 1,Settings() `Creates a Memblock from my array of Types
if file exist("DefaultSettings.dat")=1 `Checks for an existing save file
delete file "DefaultSettings.dat"
endif
make file "DefaultSettings.dat" `Create and open the file.
open to write 1,"DefaultSettings.dat"
write memblock 1,1 `Write to the File
close file 1 `Close the file and tidy up memblock.
delete memblock 1
cls
text 200,200,"Settings Saved"
text 200,210,"Press any Key to Exit"
sync
wait key
end
endif
The array I'm using to store the settings is made from User Defined Types and not just a standard array. Since I can't simply save this array (Not sure why that is but DBPro doesn't like it) I have to convert the array into a memblock and save that.
But apparently I'm doing something wrong when opening the file. This is the first time I've used file commands, it seemed pretty straight forward but doesn't seem to work. When I get to the "Write Memblock" command I get the error that the file is not open to write.
What am I missing? Help would be greatly appreciated, I've been stumped on this for days.