Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to write all the records after ITERATE?

Status
Not open for further replies.

sunnyprogrammer

Programmer
Apr 23, 2009
1
0
0
GB
Hi,

My REXX program has the below records in the input file:

AAAAAAAAAAAAAAAAAAAAAAAAAAA
11111EEEEEEEEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFFFFFFFFFFFFF

now my rexx program is to write the records of the input file only when first 3 digits of the input record is NOT '111'.

I noticed that only the record 'AAAAAAAAAAAAAAAAAAA' is written to the output file and the record 'FFFFFFFFFFFFFFFFFFFF' is not written to the o/p file.

The Program is as below:

/*** REXX ***/
ALLOC DA(USERID.INPUT.FILE) F(INPFILE) SHR REUSE
ALLOC DA(USERID.OUTPUT.FILE) F(OUTFILE) SHR REUSE
"EXECIO * DISKR (OPEN STEM INPREC. "
"EXECIO * DISKW (OPEN STEM OUTREC. "

DO I=1 TO INPREC.0
IF SUBSTR(INPREC.I,1,3)=111 THEN
INTERATE
ELSE
OUTREC.I=INPREC.I
END

"EXECIO * DISKW (FINIS STEM OUTREC."

I referred the REXX user guide and the reference guide and learnt that when '*' is provided as line number in the EXECIO WRITE statement, it writes the data into output file until OUTREC.I has a NULL value. This is what has happened in my case.

Can any one please help me solve this problem?

Thanks very much.
 
Wow. Anyway, here are a few options:

"EXECIO * DISKR INPFILE (STEM INPREC. FINIS"
DO I=1 TO INPREC.0
IF SUBSTR(INPREC.I,1,3)=111 THEN ITERATE
ELSE QUEUE INPREC.I
END
"EXECIO "QUEUED()" DISKW OUTFILE (FINIS"


"EXECIO * DISKR INPFILE (STEM INPREC. FINIS"
O=0
DO I=1 TO INPREC.0
IF SUBSTR(INPREC.I,1,3)=111 THEN ITERATE
ELSE
O=O+1
OUTREC.O=INPREC.I
END
"EXECIO * DISKW OUTFILE (STEM OUTREC. FINIS"


DO FOREVER
"EXECIO 1 DISKR INPFILE"
IF RC=0 THEN
DO
PARSE PULL INREC
IF SUBSTR(INREC,1,3)=111 THEN ITERATE
ELSE
DO
PUSH INREC
"EXECIO 1 DISKW OUTFILE"
END
END
ELSE LEAVE
END
"EXECIO 0 DISKR INPFILE (FINIS"
"EXECIO 0 DISKW OUTFILE (FINIS"

The last option is good for when there is an undetermined amount of input records that may not be able to be loaded into a single stem variable without exhausting the available storage.
 
Many problems.

First, does your code really say "INTERATE"?

Then your initial EXECIOs do not specify the filenames (INPFILE and OUTFILE). You load OUTREC. but never set the index (OUTREC.0).

Lastly (and the folks here are probably sick of hearing me say it) you should nevernever write "EXECIO * DISKW". There is always enough information available to you to avoid that asterisk when writing. Except in this case.

Code:
/*** REXX ***/
ALLOC DA(USERID.INPUT.FILE) F(INPFILE) SHR REUSE
ALLOC DA(USERID.OUTPUT.FILE) F(OUTFILE) SHR REUSE
"EXECIO * DISKR INPFILE (STEM INPREC. "
outrec. = 0
DO I=1 TO INPREC.0
   IF SUBSTR(INPREC.I,1,3)=111 THEN
      ITERATE
   ELSE,   /*     ;-)    */
      parse value outrec.0+1 inprec.i  with,
                  $z$        outrec.$z$  1 outrec.0  .
END
"EXECIO" outrec.0 "DISKW (FINIS STEM OUTREC."


Frank Clarke
--America's source for adverse opinions since 1943.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top