:
EXECIO Example 6 (continued)
IF rc = 0 THEN /* If write was successful */
DO
SAY
SAY newvar.0 "records were written to 'all.sample.data'"
END
ELSE
DO
exec_RC = RC /* Save exec return code */
SAY
SAY "Error during 1st EXECIO ... DISKW, return code is " RC
SAY
END
END
ELSE
DO
exec_RC = RC /* Save exec return code */
SAY
SAY "Error during 1st EXECIO ... DISKR, return code is " RC
SAY
END
IF exec_RC = 0 THEN /* If no errors so far... continue */
DO
/***************************************************************/
/* At this time, the stem variables newvar.0 through newvar.20 */
/* will contain residual data from the previous EXECIO. We */
/* issue the "DROP newvar." instruction to clear these residual*/
/* values from the stem. */
/***************************************************************/
DROP newvar. /* Set all stem variables to their
uninitialized state */
/***************************************************************/
/* Read all records from 'sample2.data' and append them to the */
/* end of 'all.sample.data'. */
/***************************************************************/
"EXECIO * DISKR myindd2 (STEM newvar. FINIS" /*Read all records*/
IF rc = 0 THEN /* If read was successful */
DO
/*************************************************************/
/* At this point, newvar.0 should be 10, indicating 10 */
/* records have been read. Stem variables newvar.1, newvar.2,*/
/* ... through newvar.10 will contain the 10 records. If we */
/* had not cleared the stem newvar. with the previous DROP */
/* instruction, variables newvar.11 through newvar.20 would */
/* still contain records 11 through 20 from the first data */
/* set. However, we would know that these values were not */
/* read by the last EXECIO DISKR since the current newvar.0 */
/* variable indicates that only 10 records were read by */
/* that last EXECIO. */
/*************************************************************/
Figure 8. EXECIO Example 6 (continued)
Using EXECIO to Process Information ...
Chapter 12. Processing Data and Input/Output Processing 169