Rexx defines Stream class methods to handle input and output and maintains
the I/O functions for input and output externals. Using a mixture of Rexx
I/O methods and Rexx I/O functions can cause unpredictable results. For example,
using the LINEOUT method and the LINEOUT function on the same persistent stream
object can cause overlays.
When a Rexx I/O function creates a stream object, the language processor
maintains the stream object. When a Rexx I/O method creates a stream object,
it is returned to the program to be maintained. Because of this, when Rexx
I/O methods and Rexx I/O functions referring to the same stream are in the
same program, there are two separate stream objects with different read and
write pointers. The program needs to synchronize the read and write pointers
of both stream objects, or overlays occur.
To obtain a stream object (for example,
MYFIL), you could use:
Example 14.1. Obtaining a stream object
MyStream=.stream~new("MYFIL")
You can manipulate stream objects with character or line methods:
In addition to stream objects, the language processor defines an external
data queue object for interprogram communication. This queue object understands
line functions only.
A stream object
can have a variety of sources or destinations including files, serial interfaces,
displays, or networks. It can be
transient or dynamic, for example, data sent
or received over a serial interface, or persistent in a static form, for
example, a disk file.
Housekeeping for stream objects
(opening and closing files, for example) is not explicitly part of the language
definition. However, Rexx provides methods, such as CHARIN and LINEIN, that
are independent of the operating system and include housekeeping. The COMMAND
method provides the stream_command
argument for those situations
that require more granular access to operating system interfaces.