EasyManua.ls Logo

IBM TSO/E REXX - Page 184

IBM TSO/E REXX
242 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
EXECIO Example 5
/**************************** REXX *********************************/
/* This exec illustrates the use of "EXECIO 0 ..." to open, empty, */
/* or close a file. It reads records from file indd, allocated */
/* to 'sams.input.dataset', and writes selected records to file */
/* outdd, allocated to 'sams.output.dataset'. In this example, the */
/* data set 'smas.input.dataset' contains variable-length records */
/* (RECFM = VB). */
/*******************************************************************/
"FREE FI(outdd)"
"FREE FI(indd)"
"ALLOC FI(outdd) DA('sams.output.dataset') OLD REUSE"
"ALLOC FI(indd) DA('sams.input.dataset') SHR REUSE"
eofflag = 2 /* Return code to indicate end-of-file */
return_code = 0 /* Initialize return code */
in_ctr = 0 /* Initialize # of lines read */
out_ctr = 0 /* Initialize # of lines written */
/*******************************************************************/
/* Open the indd file, but do not read any records yet. All */
/* records will be read and processed within the loop body. */
/*******************************************************************/
"EXECIO 0 DISKR indd (OPEN" /* Open indd */
/*******************************************************************/
/* Now read all lines from indd, starting at line 1, and copy */
/* selected lines to outdd. */
/*******************************************************************/
DO WHILE (return_code ¬ = eofflag) /* Loop while not end-of-file */
'EXECIO 1 DISKR indd' /* Read 1 line to the data stack */
return_code = rc /* Save execio rc */
IF return_code = 0 THEN /* Get a line ok? */
DO /* Yes */
in_ctr = in_ctr + 1 /* Increment input line ctr */
PARSE PULL line.1 /* Pull line just read from stack*/
IF LENGTH(line.1) > 10 then /* If line linger than 10 chars */
DO
"EXECIO 1 DISKW outdd (STEM line." /* Write it to outdd */
out_ctr = out_ctr + 1 /* Increment output line ctr */
END
END
END "EXECIO 0 DISKR indd (FINIS" /* Close the input file, indd */
IF out_ctr > 0 THEN /* Were any lines written to outdd?*/
DO /* Yes. So outdd is now open */
Figure 5. EXECIO Example 5
Using EXECIO to Process Information ...
166
z/OS V1R1.0 TSO/E REXX Users Guide

Table of Contents

Related product manuals