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)”
Nice little & simple code ; Thanks !