Shouldn’t Arg(1) be something like Arg(n) ? Seems like your processing the same file regardless of the number of arguments specified.
Where is the error occurring? Matt Hogstrom “It may be cognitive, but, it ain’t intuitive." — Hogstrom > On Sep 10, 2022, at 7:45 PM, Charles Mills <[email protected]> wrote: > > I am working on a Rexx program that reads one or more UNIX files. (And > please, don't beat me up for Rexx; we can have the "superiority of Python" > discussion another day.) > > The logic works for the first file, but if there is a second file the read > fails with a -21, which I interpret as "bad fd." (Am I wrong about that?) > > Here are the read and open routines. The read routine gets called with the > file name. It's getting that right because the first file works (and the > second file works if it is first). There is no error printed by FileOpen. I > can see from the Print at the start of ReadOneFile that the filename is > correct. How could the fd be bad if the open succeeds? > > ReadOneLogFile: > If IsVerbose Then Call Print "ReadOneLogFile:" Arg(1) > > ADDRESS SYSCALL > Call FileOpen Arg(1) > > Do Forever > "read" Filefd "record" LogFileRecLen > If Length(record) <> LogFileRecLen Then Leave > > /* snip */ > > End /* Read records forever */ > > "close" Filefd > > Return > > FileOpen: > /* Open the file */ > "open" Arg(1) O_RDONLY > Filefd = retval > if RC = -1 Then Do > Call Print "Error from Log File open. RC =" RC errno errnojr > Signal EndProgram > End /* RC <> 0 */ > Return > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
