More about Stream Objects

To use streams in Object REXX, you create new instances of the Stream class. These "stream objects" represent the various data sources and destinations available to your program, such as hard disks, CD-ROMs. keyboards, displays, printers, serial interfaces, networks, and so on. Because these sources are represented as objects, you can work with them in similar (but not identical) ways.

Stream objects can be "transient" or "persistent." An example of a transient (or dynamic) stream object is a serial interface. Data can be sent or received from serial interfaces, but the data is not "stored" permanently by the serial interface itself. Consequently, you cannot, for example, seek to a position in the data stream. Once you read or write it, the data cannot be read again.

A disk file is an example of a persistent stream object. Because the data is stored on disk, you can seek forward and backwards in the stream and read data that you have previously read. REXX maintains separate read and write pointers to a stream. You can move the pointers independently using arguments on methods such as LINEIN, LINEOUT, CHARIN, and CHAROUT. REXX also provides SEEK and POSITION methods for setting the read and write positions. (We'll discuss read and write positioning in a later section.)


[Back: Input and Output]
[Next: Reading a Text File]