Re: Short records on unformatted reads



Thomas Koenig wrote:

(snip)

If I replace the line
read (10, err=20) ia with
read (10, err=20) ia(1), ia(2)
or
read (10, err=20) (ia(i),i=1,2)

(and add integer::i as appropriate above)

then I would expect ia(1) to be defined, though.

More likely, but still not required.

The one I remember from many years ago when it happened to me
on a DEC compiler, (I think VAX/VMS V4 or so) something like:

READ(5,*,END=3) (A(J),J=1,100)

I expected that when the END= exit was taken that the elements
of A(I) that had been read would be assigned, and that J would
be one more than the last index stored. This was before the
web, almost before internet, and I had no access to a copy of
the standard. I thought about sending in a bug report to DEC,
but never did.

I found out later (mostly from this group) that the standard
didn't, and doesn't, require that. Implied DO is not a DO
loop that keeps its value on exit.

With either an array or with an implied DO it might be done on
one call to the I/O routine, which may then take the END=
exit before storing anything. With ia(1),ia(2) it will more likely
be two calls to the I/O routine, which may store ia(1) before
returning, but it is not required. There is no legal way to determine
that it did or didn't, either.

It was not much later that I started working with C (on a unix machine),
and finding that C made some low level I/O problems much easier may have
been one reason I started doing more in C. The equivalent C routines,
either formatted or unformatted, do guarantee that you get all the values before error or EOF, and that you can find out how many you got.

-- glen

.



Relevant Pages

  • Re: *** glibc detected *** corrupted double-linked list: 0x0804b
    ... >> What is _exit? ... Is there some reason the standard function won't work ...
    (comp.lang.c)
  • Re: _exit and redirection problem
    ... The problem is that your are mixing two kinds of I/O: ... Native unix I/o and standard C I/O. ... And when you use the _exit call, ... snip ... ...
    (comp.unix.programmer)
  • Re: If you were inventing CoBOL...
    ... I can't get COBOL to produce a *floating* version of the most common ... EXIT PARAGRAPH and EXIT SECTION provide good support for structure ... disallowed in other contexts in the '02 standard. ... EXIT PARAGRAPH and EXIT SECTION are big helps here. ...
    (comp.lang.cobol)
  • Re: Is it possible to use the value of the PROGRAM ID within the source code?
    ... This was used by some compilers to generate null code that ... I can't recall a mandatory EXIT, even on the earliest IBM compilers. ... >paragraph without a statement until the '74 standard. ... During meetings to formulate a Programming Standard, ...
    (comp.lang.cobol)
  • Re: EXIT SECTION/PARAGRAPH
    ... ISO2002 bubble ... But they only mark EXIT PARAGRAPH/SECTION/CYCLE with MF bubbles. ... conform to the '02 Standard for this feature. ... are you assuming that EXIT PARAGRAPH as an ...
    (comp.lang.cobol)