Product SiteDocumentation Site

5.2.4.17. open


         +-(BOTH-| Write Options |--+  +-SHARED-----+
>>-open--+--------------------------+--+------------+----------->
         +-(READ--------------------+  +-SHAREREAD--+
         +-(WRITE-| Write Options |-+  +-SHAREWRITE-+

   +-----------------------------------+
   V                                   |
>----+-------------------------------+-+--+---+----------------><
     +-NOBUFFER----------------------+    +-)-+
     +-BINARY--+-------------------+-+
               +-RECLENGTH--length-+

Write Options:

   +-------------+
   V +-APPEND--+ |
|----+---------+-+----------------------------------------------|
     +-REPLACE-+

Opens the stream and returns READY:. If the method is unsuccessful, it returns an error message string in the same form that the description method uses.
For most error conditions, the additional information is in the form of a numeric return code. This return code is the value of ERRNO, which is set whenever one of the file system primitives returns with a -1.
By default, open opens the stream for both reading and writing data, for example: 'open BOTH'. To specify that the stream be only opened for input or output, specify READ or WRITE.
The options for the open method are:
READ
Opens the stream for input only.
WRITE
Opens the stream for output only.
BOTH
Opens the stream for both input and output. (This is the default.) The stream maintains separate read and write pointers.
APPEND
Positions the write pointer at the end of the stream. (This is the default.) The write pointer cannot be moved anywhere within the extent of the file as it existed when the file was opened.
REPLACE
Sets the write pointer to the beginning of the stream and truncates the file. In other words, this option deletes all data that was in the stream when opened.
SHARED
Enables another process to work with the stream in a shared mode. (This is the default.) This mode must be compatible with the shared mode (SHARED, SHAREREAD, or SHAREWRITE) used by the process that opened the stream.
SHAREREAD
Enables another process to read the stream in a shared mode.
SHAREWRITE
Enables another process to write the stream in a shared mode.
NOBUFFER
Turns off buffering of the stream. All data written to the stream is flushed immediately to the operating system for writing. This option can have a severe impact on output performance. Use it only when data integrity is a concern, or to force interleaved output to a stream to appear in the exact order in which it was written.
BINARY
Opens the stream in binary mode. This means that line-end characters are ignored; they are treated like any other byte of data. This is for processing binary record data using the line operations.

Note

Specifying the BINARY option for a stream that does not exist but is opened for writing also requires the RECLENGTH option to be specified. Omitting the RECLENGTH option in this case raises an error condition.
RECLENGTH length
Allows the specification of an exact length for each line in a stream. This allows line operations on binary-mode streams to operate on individual fixed-length records. Without this option, line operations on binary-mode files operate on the entire file (for example, as if you specified the RECLENGTH option with a length equal to that of the file). The length must be 1 or greater.

Example 5.119. Stream object - OPEN method

stream_name~open
stream_name~open("write")
stream_name~open("read")