open considerations for file I/O

In the context of file I/O that does not involve databases, the EGL open statement opens the file that is associated with a given record variable.
The following table describes how statements present in the program impact the status of the file:
Statement present in the program File status
EGL get statements only Open for input
EGL add statements only Open for output
Both EGL get and add statements Open for both input and output
These EGL get and add statements do not have to be executed, but they must be present in the program. As files are opened automatically by the EGL get or add statements, you can use the EGL open statement to clear the file without any actual I/O being done.

Syntax

Syntax diagram for the open statement using file I/O
Note: The keyword file is required to indicate that this is a file I/O open rather than an SQL open.
for recordVariable
The keyword for followed by the name of an indexed, relative, or serial record that is associated with the file being opened.

Limitation

The limitations of the EGL open statement in Java and the debugger are as follows:
  • The file will always be open for output, regardless of whether add or get statements are present.
  • The file will only be cleared when replace = yes is defined in the file association.

Example

The following example shows how to clear a file:

      open file for myRecordVariable;
      if (0 == 1)
          add myRecordVariable;
      end
      close myRecordVariable;

Feedback