Saving & Loading Files

Previous topic - Next topic

Kimaro

Can someone please give me an idea how to save and load string data and numeric files to hard drive from within GLBasic. :S

MrTAToad

This is an example of saving a string to a file :

Code (glbasic) Select
IF OPENFILE(1,"example.txt",0)
WRITESTR 1,"Write some data to file"
ENDIF


Writing numbers can be done using WRITEBYTE, WRITEWORD, WRITEIEEE depending on the type of number you want to write.  Reading is done in the same way, except the third parameter in OPENFILE should be changed to a 1, and all corresponding WRITE statements should be changed to READ

Kimaro

Thanks for the reply. I'm finding quite a few variations from the older BASIC that I was familiar with on the Commodore 64 and the Amiga. Luckily, stuff like FOR-NEXT loops and DIM arrays are pretty much the same.
Thanks again.
:)