Open

Description

Opens a file handle in one of 4 different modes.

NOTE: If a file is created, the file modification date is set to the current time from the built-in RTC (Real Time Clock). You can change the time by using the Time command. You can modify the file modification date using the Change Timestamp command.

Format

O fh mode path

Parameters

  • fh is a file handle (1 - 4). Use the Free Handle command to get a free file handle.
  • mode is one of:
    • R” – Open in read-only mode. No data can be written to the file.
      • The filename in the path must exist.
    • W” – Open in write mode. This opens a new file for writing. The file must not already exist.
      • The filename in the path must NOT already exist.
    • A” – Open in append mode. This opens a new or existing file for writing. Once opened, the file handle is positioned at the end of the file.
      • If the filename in the path does not exist, it will be created.
    • RW” – Open in read/write mode. This opens a new or existing file for reading and/or writing. Once opened, the file handle is positioned at the beginning of the file.
      • If the filename in the path does not exist, it will be created.
  • path is the absolute path to a file/directory. A properly formatted path must begin with a “/” (forward slash) and begins at the root directory. Subdirectories are separated with “/” (forward slash).
    • e.g. /logs/january/jan3.log

Response Format

NULLSuccess
EnnAn error occurred

Example

Open a file for reading:

O 1 R /LOGS/JANUARY/JAN03.LOG

Open a file for reading and writing:

O 1 RW /www/httpdocs/chatlog/chatlog002.log