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

One thought on “REXX – Reading a sequential file into a STEM (array)”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.