On Sun, 11 Sep 2022 10:02:53 +0200, Bernd Oppolzer wrote:

>Once again wrong, my e-Mail client is fooling me. Next try:
> 
It's way hard nowadays to Copy/Paste from manuals preserving formatting.

>'open' path, O_rdwr+O_creat+O_trunc, 660
>if retval=-1 then do
>     say 'file not opened, error codes' errno errnojr
>     return
>end
>fd=retval
>
>
>> Am 11.09.2022 um 09:57 schrieb Bernd Oppolzer:
>>> Why is there suddenly the variable RC used to test the outcome of OPEN?
>>> 
Yes.  Beware of the exception:  SYSCALL spqwnp (at least formerly) set
RC, not RETVAL.  Bad historical reasons.


>>> the returned fd and the code to test the success of OPEN
>>> is both in the variable retval, not RC.
>>>
>>> And: it would be better to assign the value of retval to
>>> fd after the test for success.
>>>
ObHeisenberg, it is a habit of Shell programmers to assign the status
to a variable immediately, lest reporting the status change the status.

In Charles's (pseudocode?) example, the main program fails to test
for failure of FileOpen.  Is it his intent with "Signal EndProgram" to
terminate all processing on the first error encountered?

>>> Am 11.09.2022 um 01:45 schrieb Charles Mills:
>>>>    ...
>>>> 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

-- 
gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to