So from what i understand you need help reading and writing in a file? Well, here is a simple tutorial that covers basic reading and writing and then some interesting stuff like arrays. Some even more crazy stuff can be done like writing multiple variables to one line or writing file names to a line and then reading that file name, opening the file and reading the contents of that file (which i had to do for the project vertex editor since each part is separate).
Note = This requires a good understanding of variables -_-
So lets start of simple and we'll work our way into exporting data that needs to be found in other files (like i had to do for the ship editor)
Alright, lets say we have some sample data that we need to export as follows :
Name$ = Gokz
Health# = 10.0001
The code is real simple :
if file exist(path$) then delete file path$
open to write 1,path$
write string name
write string str$(health#) or write float health#
close file 1
simple, right? You might ask why i wrote health as a string, well you can do it either way but i stick with writing the data as a string for variables that are floats because sometimes i want to cut off some of the decimal places on the float and you can do that with the str$() command.
Alright so now lets read it back into the game
if file exist(path$)
open to read path$
read string Name$
read string e$
Health# = val(e$)
endif
Alright so in this code, i open the file and i read the data in the same way that i wrote the data. Its really easy because once the file is open it is sitting on the first line, and when we wrote the data we wrote the name in the first line, thus we read in the name first. the weird thing is that i read the string into a temp val e$ and then put it in the health variable. This is done for the obvious reason that i can't do "read string health#" because health# is a float. I'm not sure if you can replace that line with read float Health# ...feel free to try it out.
---------Its getting late maybe my writing is really bad...-------
Alright lets get more advanced,
I have an array i need to write into the data file that can have a maximum of ten values in it.
This is what i would do:
read through the array and write each piece of data in, when you find a spot in the array thats blank, stop. Then write a blank line or anything you could use to tell your self that this is the end of writing in the array.
While array(x)<>""
write string array(1)
inc x
endwhile
write string "-----"
so as you can see i wrote a "-----" after i wrote all the array data to tell my self that i have finished writing array data.
now when i am reading the file all you have to do is this :
read string e$
while e$<>"-----"
array(x) = e$
inc x
read string e$
endwhile
What i'm doing here is that i'm reading in the string and checking if that line has the "----" if it does that means we have no more array parts to read in, if not we save the line into the array.
-------Guess i better go to bed...I'll update it if you find it usefull----------------
Hope this helps
around here.. normal's just a setting on a hair dryer