Thread: File I/O Tool
View Single Post
File I/O Tool
Old
arty-fishL
Senior Member
 
arty-fishL's Avatar
 
Status: Offline
Posts: 1,878
Join Date: Mar 2008
Location: In the corner of your eye
Lightbulb File I/O Tool - 06-14-2011, 05:15 PM

This is a neat file I/O tool I made for TauTrumpsPi.
Import the object into the world you want to use it in.
Don't rename it and don't delete any of its variables, methods or events.

Set IOTool's variable named current_file to the file to be used. Change it when necessary.
Use any of its methods wherever required.
Some methods have basic help/info in comments inside them.
Any method that returns a value (eg read_all or get_lines) will write its value to IOTool's variable named returnString (or returnNumber for get_lines).

Update 1.1 - should work perfectly now.
Update 1.2 - now it actually definitely works; trialled and tested.

New Version Available - Save Tool - for specifically saving and loading variables




Read below only if you require help:

get_value - returns to returnString - parameter value is the name of the value key - returns info about the file (eg size).
new_file - returns none - parameter filename is the complete folder, file,ext name (ie C:\Users\Me\Documents\blank.txt).
new_folder - returns none - parameter dirname is the complete pathname of the directory (ie C:\Users\Me\Documents\folder).
read_all - returns to returnString - no parameters - reads the entire file.
read_line - returns to returnString -parameter line is the line to read - reads only a given line from the file.
get_lines - returns to returnNumber -no parameters - returns the number of lines of text in the file.
write - returns none - parameter text is the string to write with - writes over everything in the file.
write_line - returns none - parameter text is the string to write with, line is the line to write over - writes over everything on only the specified line in the file.
write_append - returns none - parameter text is the string to write with - writes onto the end of the file, retaining any text already in it.
delete_file - returns none - no parameters - completely removes the file from disc.
replace_file - returns none - parameter file_to_overwrite_with is the complete filename of the file to write with - replaces the current file with the contents of another file, replaces in binary, so can replace with images etc.
rename_file - returns none - parameter name is the new name to give the file, set full_path to true to change complete filename; or to false just to change name relative to the director
y it is in - renames the file.

Support me by using this DOWNLOAD link (AdF.ly)
Attached Files
File Type: a2c IOTool.a2c (37.4 KB, 86 views)

Last edited by arty-fishL; 05-08-2012 at 05:24 PM. Reason: updated - 1.2
   
Reply With Quote