Loading

REXX – Reading a sequential file into a STEM (array)

The below REXX program gets a PS file my.seq.dsn into a STEM (array).
We can immediately FREE the file, since the file data has now copied to an internal variable.

/******REXX******/
ADDRESS TSO                                     
"ALLOC F(INFILE) DSN('my.seq.dsn') SHR REU"    
/* INFILE is a logical name for the file */
"EXECIO * DISKR INFILE ( FINIS STEM MYFILE." 
/* MYFILE is the stem (array) that holds the data */
"FREE F(INFILE)"
I = 1
/* MYFILE.0 will have the number of */
/* elements in the stem             */
DO WHILE I <= MYFILE.0
   SAY ' LINE ' I ' : ' MYFILE.I
   I = I + 1
END
EXIT

INFILE – my.seq.dsn

MY
DATA
SET
IS THIS

Result of the above Rexx program is:

 LINE 1 : MY
 LINE 2 : DATA
 LINE 3 : SET
 LINE 4 : IS THIS

Related Posts




blog comments powered by Disqus

There's 1 Comment So Far

  •   Selvakumar
    March 7th, 2012 at 5:57 am

    Nice little & simple code ; Thanks !

Share your thoughts, leave a comment!