Text files turtorials
Using Text Files??? Well here is a simple turtorial to show its functions
1. Turtorial about text files
In GameMaker i haven't figured out a way to create a textfile so if anyone knows please PM me at the GMC or UGMC or MSN me at millzyman1@hotmail.com
In a text file there are certain things you can do......
rename a text file
Change it extention
copy it.... (great for backups :))
But the most important function you MUST do in a text file functions is file_text_close(fileid or filename) for instances
[CODE]
//example
file_text_open_write("example.txt")
file_text_write_string("example.txt","hello world")
file_text_close("example.txt")
[/CODE]
2. Using File ids
File ids are very simple to use... (or the way i think how you use it) i make a fileid by using a variable, in most codes you find f=text file function
Example
[CODE]
f=file_text_open_write("example.txt")
file_text_write_string(f,"hello world")
file_text_close(f)
[/CODE]
3. Using Write string or real functions
If using strings and reals you can use two easy functions
file_text_write_string
and
file_text_write_real
Both have the same arguments (fname//filename,str//string or real)
Also if you want to skip a line then to do so you use file_text_ln(filename)
4. Reading functions
When collecting the data from a text file you would normally do
[CODE]
f=file_text_open_read("example.txt")
d=file_text_read_string(f)
if d=str
then
file_text_close(f)
room_goto_next()
[/CODE]
Also you may want to skip a line.... the function is text_open_readln(fname)
5. Renaming,Extention changing and copying
File_Copy(filename,newfilename)
when using file copy you have to have the orginial filename and the new filename
I suggest using Save and Load scripts....
File_Rename(Oldname,Newname)
simple... just put in the old filename then you can change it to a new one
filename_change_ext(filename,newextention)
really good for converters.... or just changing files to a new extention
Thats all from me hopefully i will see you using text files in the near to distance future
1. Turtorial about text files
In GameMaker i haven't figured out a way to create a textfile so if anyone knows please PM me at the GMC or UGMC or MSN me at millzyman1@hotmail.com
In a text file there are certain things you can do......
rename a text file
Change it extention
copy it.... (great for backups :))
But the most important function you MUST do in a text file functions is file_text_close(fileid or filename) for instances
[CODE]
//example
file_text_open_write("example.txt")
file_text_write_string("example.txt","hello world")
file_text_close("example.txt")
[/CODE]
2. Using File ids
File ids are very simple to use... (or the way i think how you use it) i make a fileid by using a variable, in most codes you find f=text file function
Example
[CODE]
f=file_text_open_write("example.txt")
file_text_write_string(f,"hello world")
file_text_close(f)
[/CODE]
3. Using Write string or real functions
If using strings and reals you can use two easy functions
file_text_write_string
and
file_text_write_real
Both have the same arguments (fname//filename,str//string or real)
Also if you want to skip a line then to do so you use file_text_ln(filename)
4. Reading functions
When collecting the data from a text file you would normally do
[CODE]
f=file_text_open_read("example.txt")
d=file_text_read_string(f)
if d=str
then
file_text_close(f)
room_goto_next()
[/CODE]
Also you may want to skip a line.... the function is text_open_readln(fname)
5. Renaming,Extention changing and copying
File_Copy(filename,newfilename)
when using file copy you have to have the orginial filename and the new filename
I suggest using Save and Load scripts....
File_Rename(Oldname,Newname)
simple... just put in the old filename then you can change it to a new one
filename_change_ext(filename,newextention)
really good for converters.... or just changing files to a new extention
Thats all from me hopefully i will see you using text files in the near to distance future
Labels: Advanced

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home