/* REXX | | Name: INPUTR | | Author: David Alcock | dalcock@csw.com | davea@ticnet.com | | Written: 26-Jan-1998 | | Purpose: Sample Rexx code that can be used as a template to read | an input file in record mode on any platform. | | Requirements: Rexx Anywhere! | | Disclaimer: This Rexx exec is FREEWARE. Use at your own risk. It | is provided for your enjoyment and neither David | Alcock or his employer provides any warranty for it's | use. I'd like to hear how it works on your system. */ /********************************************************************** * M o d i f i c a t i o n H i s t o r y * * Person Date Description * ---------- ----------- --------------------------------------------- * DGAlcock 26-JAN-1998 v1.0 Initial exec written; **********************************************************************/ mtype = address() /* obtain type of environment */ /*--------------------------------------------------------------------- | Read in the input file based on the environment ------------------------------------------------------------------- */ select /*-------------------------------------------------------------- | PC: OS/2, Windows 95, Windows NT, etc. ------------------------------------------------------------ */ when mtype == "CMD" | mtype == "COMMAND" then do arg filein options if lines(filein) == 0 then do say "Input file not useable: "filein exit 12 end i = 0 do while lines(filein) > 0 i = i + 1 filein.i = linein(filein) end filein.0 = i end /*-------------------------------------------------------------- | MVS (batch execution) - defaults to SYSUT1 for input ------------------------------------------------------------ */ when mtype == "MVS" then do arg options "EXECIO * DISKR SYSUT1 (FINIS STEM filein." erc = rc if erc <> 0 then do say "Error reading input file " exit 12 end if filein.0 == 0 then do say "Input file is empty" exit 12 end end /*-------------------------------------------------------------- | TSO (but not batch "MVS") ------------------------------------------------------------ */ when mtype == "TSO" then do arg filein_dsn options if filein_dsn == "" then do say "Missing input dataset name, terminating" exit end x = LISTDSI(filein_dsn) if x <> 0 then do say "Error accessing DSN:" filein_dsn say " > "sysmsglvl1 say " > "sysmsglvl2 say " > SYSREASON: "sysreason exit end filein_pdsn = sysdsname parse value filein_dsn with . "(" member ")" . if member <> "" then do filein_pdsn = filein_pdsn"("strip(member)")" end say "Processing input file "filein_pdsn filein_dd = "SYU1"random() address TSO "ALLOCATE FILE("filein_dd")" , "DA('"filein_pdsn"') SHR REUSE" "EXECIO * DISKR "filein_dd , "(FINIS STEM filein." erc = rc address TSO "FREE FILE("filein_dd")" if erc <> 0 then do say "Error reading input file: "filein_pdsn exit end if filein.0 == 0 then do say "Input file is empty: "filein_pdsn exit end if member == "" then name = "UNKNOWN" else name = member end /*-------------------------------------------------------------- | VM files ------------------------------------------------------------ */ when mtype == "CMS" then do parse arg fn ft fm "(" options fn = strip(fn) ft = strip(ft) fm = strip(fm) if fm == "" then fm = "A" else fm = translate(fm) address command "STATE" fn ft fm if rc <> 0 then do upper fn ft fm "STATE" fn ft fm if rc <> 0 then do say "File" fn ft fm "not found" exit end end vmfclear "FINIS" fn ft fm "EXECIO * DISKR "fn ft fm" (STEM FILEIN. FINIS" erc = rc if erc <> 0 then do say "Error reading input file: "fn ft fm exit end if filein.0 == 0 then do say "Input file is empty: "fn ft fm exit end name = fn"."ft end /*-------------------------------------------------------------- | Other systems that we don't support ------------------------------------------------------------ */ otherwise say "Not written to support system type: "mtype say "We do support: CMS, CMD, COMMAND, MVS and TSO" exit end /* of "select" */ /*--------------------------------------------------------------------- | From here on out, you can see the entire file contents via the | filein. array ------------------------------------------------------------------- */ say "The number of lines in the input file are: "filein.0 /*--------------------------------------------------------------------- | END END END END END - End of INPUTR exec - END END END END END ------------------------------------------------------------------- */