Skip to content

TextFile

Hyomoto edited this page Jun 24, 2021 · 3 revisions
Jump To Go Back Arguments Methods Variables

TextFile( _new )

Implements: Stream

A wrapper for text file handling.

var _file = new TextFile().open( "text.txt" );

list.from_input( _file );
Output: Will open text.txt and read its contents into list

Arguments

Name Type Purpose
_new undef No description

Methods

Jump To top read write open close finished

read( )

Returns: mixed or EOF

Throws: IllegalFileOperation

Name Type Purpose
None

Reads the next portion of the text file and returns it. If the file is not open, or the file is not opened for reading, IllegalFileOperation will be thrown.


write( values... )

Returns: self

Throws: IllegalFileOperation

Name Type Purpose
values... mixed The values to write

Writes the given values to the file. If the values are not strings, they will be converted. If the file is not open, or the file is not open for writing, IllegalFileOperation will be thrown.


open( filename, action )

Returns: self

Throws: InvalidArgumentType, FileNotFound, IllegalFileOperation

Name Type Purpose
filename string The name and path to the file to open
action int The type of action to take

Opens the specified file for futher processing. If action is not specified, the file will be opened for reading, otherwise FAST_FILE_OPEN_* should be specified. If a file is already opened, it will be closed first. If the filename is not a string, or action is an invalid type, InvalidArgumentType will be thrown. If the file does not exist, FileNotFound will be thrown. If too many files are currently open, an IllegalFileOperation will be thrown.


close( )

Returns: self

Throws: IllegalFileOperation

Name Type Purpose
None

Closes this file. No further processing can take place once closed, and will generate an error if attempted. If a file is not current open, IllegalFileOperation is thrown.


finished( )

Returns: bool

Throws: IllegalFileOperation

Name Type Purpose
None

Returns true if the end of the file has been reached. If the file isn't open, or the file isn't open for reading, IllegalFileOperation will be thrown.


Variables

Jump To top
Name Type Initial Purpose
EOF struct constant The pointer that is returned when the end of file is reached
__Operation int undefined The type of operation being performed on this file
Clone this wiki locally