FileIO

FileIO inherits Object

Construction: FileIO newObj = FileIO();

FileIO is a script object for reading and writing files.

Methods

bool Open(string aFileName)
bool Open(string aFileName, string aMode)
bool Open(Path aFileName)
bool Open(Path aFileName, string aMode)

Opens aFileName in the appropriate mode. If mode is not specified or unrecognized the default behavior Input is used.

Mode:

  • in - Read Only Default

  • out - Write Only If the file already exists, it will be overwritten.

  • append - Write Only Begins writing a new file, or appends to an existing file

Returns true if the file was opened successfully; false otherwise.

void Close()

Closes the file and clears the buffer.

string Readln()

Returns the next line of data.

string ReadToken()

Returns the next token (word) of data.

bool Eof()

Returns true if no more data remains to be read.

string Mode()

Returns a string indicating the current mode for a file that has been opened. The following values are possible.

  • in

  • out

  • append

  • none

If a file is not open, “none” will be returned.

Path Path()

Returns a Path object of the path used to open the file, as provided via the FileIO.Open method “aFileName” argument. If a file is not open at the time of this call, the path will be empty.

void Write(string aString)

Writes aString to the file.

void Writeln(string aString)

Writes aString to the file followed by a carriage return. Important to note that this Writeln is not the same as the scripting language writeln. Writeln follows the c language convention.