To update multiple lines, you can issue more than one EXECIO command
to the same data set. For example, to update Mary Leone's user ID
in addition to Amy Crandall's phone extension, write the following
instructions.
Updating Multiple Specific Lines in a Data Set
"ALLOC DA('dept5.employee.list') F(updatedd) OLD"
"EXECIO 1 DISKRU updatedd 2 (LIFO"
PULL line
PUSH 'Crandall, Amy AMY 5500'
"EXECIO 1 DISKW updatedd"
"EXECIO 1 DISKRU updatedd 5 (LIFO"
PULL line
PUSH 'Leone, Mary MARYL 5530'
"EXECIO 1 DISKW updatedd (FINIS"
"FREE F(updatedd)"
When you issue multiple EXECIO commands to the same data set before
closing it and do not specify a line number, the most current EXECIO
command begins reading where the previous one left off. Thus to scan
a data set one line at a time and allow a user at a terminal to update
each line, you might write the following exec.
Example of Scanning Each Line for Update
/***************************** REXX ********************************/
/* This exec scans a data set whose name and size are specified by */
/* a user. The user is given the option of changing each line as */
/* it appears. If there is no change to the line, the user presses*/
/* Enter key to indicate that there is no change. If there is a */
/* change to the line, the user types the entire line with the */
/* change and the new line is returned to the data set. */
/*******************************************************************/
PARSE ARG name numlines /* Get data set name and size from user */
"ALLOC DA("name") F(updatedd) OLD"
eof = 'NO' /* Initialize end-of-file flag */
DO i = 1 to numlines WHILE eof = 'NO'
"EXECIO 1 DISKRU updatedd" /* Queue the next line on the stack */
IF RC = 2 THEN /* Return code indicates end-of-file */
eof = 'YES'
ELSE
DO
PARSE PULL line
SAY 'Please make changes to the following line.'
SAY 'If you have no changes, press ENTER.'
SAY line
PARSE PULL newline
IF newline = '' THEN NOP
ELSE
DO
PUSH newline
"EXECIO 1 DISKW updatedd"
END
END
END