General EQWatcher Concepts > Venturing into the Unknown > File I/O
List of commands
Close(file)
Create(file, string filename)
eof(file)
FilePos(file)
IsOpen(file)
Open(file, string filename)
Read(file, integer length)
ReadLN(file)
Seek(file, integer position)
Size(file)
Truncate(file)
Write(file, string data)
WriteCH(file, char data)
WriteLN(file, string data)
Close(file) command
Closes a file
Return value
none
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
Example
Create(file, string filename) Command
Opens a file. If the file does not exist, it is created.
Return value
none
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
filename
The name of the file, paths are relative to the EQWatcher directory. You may use full or relative paths.
Example
eof(file) command
Checks if the end-of-file has been reached.
Return value
A Boolean value, indicating true if the end-of-file has been reached, or false if it has not.
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
Example
FilePos(file) command
Gets the current read/write position of the file.
Return value
An integer value indicating the current read/write position of the file.
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
Example
IsOpen(file) command
Checks if the file is successfully opened
Return value
A Boolean value, indicating true if the file has been successfully opened, or false if it has not.
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
Example
Open(file, string filename) Command
Opens a file. If the file does not exist, the operation is unsuccessful
Return value
none
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
filename
The name of the file, paths are relative to the EQWatcher directory. You may use full or relative paths.
Example
Read(file, integer length) Command
Reads data of a set length from the file
Return value
A string containing data read from the file, may or may not be the correct length depending on end-of-file and possibly other factors.
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
length
The number of characters to read from the file
Example
ReadLN(file) Command
Reads data from the file up to the next CR/LF or end-of-file, whichever comes first (reads a line)
Return value
A string containing data read from the file
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
Example
Seek(file, integer position) Command
Sets the current read/write position within the file.
Return value
none
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
position
The position to move the current read/write pointer to
Example
Size(file) command
Gets the size of the file in bytes.
Return value
An integer value indicating the size of the file, given in bytes.
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
Example
Truncate(file) command
Truncates the file at the current read/write position (any trailing data is deleted)
Return value
none
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
Example
Write(file, string data) Command
Writes string data to the file, without adding CR/LF (end line). To write a line to a file, see WriteLN
Return value
none
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
data
The data to be written.
Example
WriteCH(file, char data) Command
Writes a single byte to the file
Return value
none
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
data
The data to be written.
Example
WriteLN(file, string data) Command
Writes string data to the file, adding CR/LF (end line). To write to the file without adding this, see Write
Return value
none
Parameters
file
The file number to work with. This MAY NOT be a variable. Valid numbers are 0, 1, and 2. This may be changed later.
data
The data to be written.
Example