EQWatcher Evolution > Scripting > File I/O Functions
Each script can have 3 files open at any given time. They must be referenced directly by a number, NOT by a variable. Identifiers can be defined to use instead of the actual number.
List of commands
Close, CopyFile, Create, eof, FileExists, FilePos, GetFileProtect, IsOpen, mkdir, Open, OpenR, Read, ReadLN, Seek, Size, Truncate, Write, WriteCH, WriteLN
The "Close" Command
This command closes an open file.
Syntax:
Close([File])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
The "CopyFile" Command
This command creates a copy of an existing file. The destination may already exist, but may not be in use by another process. The source MUST already exist, and may not be open for writing by another process.
Syntax:
CopyFile([Source],[Destination])
Source: The file to be copied.
Destination: The filename of the new copy.
Return Value:
This command returns a boolean value (true or false) indicating whether the copy operation was successful.
The "Create" Command
This command opens a file. If the file does not exist, it is created. Use IsOpen afterward to determine if the file was successfully opened.
Syntax:
Create([File],[Filename])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Filename: The filename of the file to open (and create if needed).
The "eof" Command
This command checks if the end-of-file has been reached.
Syntax:
eof([File])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Return Value:
This command returns a boolean value (true or false) indicating whether the end-of-file has been reached.
The "FileExists" Command
This command checks if a file exists.
Syntax:
FileExists([Filename])
Filename: The filename to check for. This MAY be a standard wildcard.
Return Value:
This command returns a boolean value (true or false) indicating whether the file (or a file matching the wildcard) exists.
The "FilePos" Command
This command retrieves the current read/write position of a file.
Syntax:
FilePos([File])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Return Value:
This command returns the current read/write position of the file.
The "GetFileProtect" Command
This command checks if the file protection check box is checked, preventing certain files from being accessed.
Syntax:
GetFileProtect()
Return Value:
This command returns a boolean value (true or false) indicating whether file protection is enabled or not.
The "IsOpen" Command
This command checks if the file is successfully opened.
Syntax:
IsOpen([File])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Return Value:
This command returns a boolean value (true or false) indicating whether the file is currently open or not.
The "mkdir" Command
This command attempts to create a directory. This is NOT recursive, and will only try to create the bottom level directory if possible. File protection applies to this when attempts are made to create a directory outside the EQWatcher Evolution directory.
Syntax:
mkdir([Path])
Path: The path to attempt to create.
Return Value:
This command returns a boolean value (true or false) indicating whether the directory was successfully created. If the directory already exists, this will also return true.
The "Open" Command
This command opens a file for reading and writing. If the file does not exist, the operation is unsuccessful. Use IsOpen afterward to determine if the file was successfully opened.
Syntax:
Open([File],[Filename])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Filename: The filename of the file to open.
The "OpenR" Command
This command opens a file for reading only. If the file does not exist, the operation is unsuccessful. Use IsOpen afterward to determine if the file was successfully opened.
Syntax:
OpenR([File],[Filename])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Filename: The filename of the file to open.
The "Read" Command
This command reads data of a set length from the file.
Syntax:
Read([File],[Length])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Length: The number of characters to read from the file.
Return Value:
This command returns a string containing data read from the file. This may or may not be the desired length, depending on end-of-file and possibly other factors.
The "ReadLN" Command
This command reads up to the next CR/LF or end-of-file, whichever comes first (reads a line)
Syntax:
ReadLN([File])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Return Value:
This command returns a string containing data read from the file.
The "Seek" Command
This command sets the current read/write position within the file.
Syntax:
Seek([File],[Index])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Index: The position to move the current read/write pointer to.
The "Size" Command
This command retrieves the length of a file in bytes.
Syntax:
Size([File])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Return Value:
This command returns the size of the file.
The "Truncate" Command
This command truncates the file at the current read/write position (any trailing data is deleted)
Syntax:
Truncate([File])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
The "Write" Command
This command writes string data to the file, without adding CR/LF (end line). To write a line to a file, see WriteLN.
Syntax:
Write([File],[Data])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Data: The string data to write to the file.
The "WriteCH" Command
This command writes a character to the file.
Syntax:
WriteCH([File],[Data])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Data: The character to write to the file.
The "WriteLN" Command
This command writes string data to the file, adding CR/LF (writes a line).
Syntax:
WriteLN([File],[Data])
File: This must be a constant number (0, 1, or 2). You may of course create and use identifiers for your own use here.
Data: The string data to write to the file.