Writing to file-Reading from file?

BlitzMax Forums/BlitzMax Beginners Area/Writing to file-Reading from file?

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

It depends what type your Array is but the main framework should something like that:

if filetype("yourfile.dat") = 0 then 
 new_file = createfile("yourfile.dat")
end if

'To open the file for writing :
write_file = Writefile("yourfile.dat")
For x = 1 to 30
Writeint(write_file,YourArray[x])
next
Closestream(write_file)

'To open the file for Reading :
Read_file = Readfile("yourfile.dat")

while not EOF(Read_file)
YourArray[X] = Readint(Read_file)
x = x + 1
wend

Closestream(Read_file)

' You can also use Openfile with your File to open it for read and write the same time


Yes you can use incbin with Textfiles but you can only read them. Writing of Incbin files is not allowed.
Don't forget to change the path of your file to 'incbin::yourfile.dat' when using incbin.