Accessing Data within a Stream
REXX regards all external data as streams of information. Nonetheless, these streams can take different forms. A minidisk file, for example, differs from a spool file in that it has a static, physical form. A minidisk file is one example of a persistent stream. This means a program can read from or write to anywhere in the file.
As a program reads a file, REXX keeps a place marker, called the read position, that points to the next character (or line).
The same is true when writing. REXX maintains a write position that marks the next place to write.
You can specify another position for the read or write positions
by giving additional arguments on the stream functions LINEIN, LINEOUT,
CHARIN, CHAROUT, or by using the LINEPOS option of
the STREAM function (see STREAM
in the
z/VM: REXX/VM Reference.)
For more information about these functions, see z/VM: REXX/VM Reference.
A stream of data may be a string of characters separated by line end (LINEEND) characters. When you open a stream, you can specify the type of file and if LINEEND characters are important. If the opened stream specified BINARY, it means that all character codes may be present in the data stream, and no indication of LINEEND characters will be provided or searched for. If the TEXT option is specified, it means LINEEND characters are appended to the end of each line when passing data to the user on character input operations. These LINEEND characters are never written to the data stream. Line operations are not affected by this parameter, only character operations. Figure 1 shows how a LINEEND character is inserted:
/* CHAROUT2 EXEC */
lend= '15'x /* line end character = 15'x' */
file = 'TESTIT FILE A' /* file name */
Z = stream(file,C,'OPEN TEXT lineend 15')/* open with TEXT and lineend */
g = charout(file,'abc'lend'def') /* write abc on one line */
/* write def on next line */
Z = stream(file,C,'CLOSE') /* close the file */
exit /* end the program */
/* Output file would look like: */
/* . */
/* . */
/* abc */
/* def */
For more information on LINEEND and TEXT files, see STREAM
in
z/VM: REXX/VM Reference.