Alice Community  

Go Back   Alice Community > Alice 2 > Share Objects

Thread Tools Display Modes
Prev Previous Post   Next Post Next
File I/O Tool
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, 06: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 (
Attached Files
File Type: a2c IOTool.a2c (37.4 KB, 86 views)

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.