Re: Fortran 77: Reading empty string
- From: nospam@xxxxxxxxxxxxx (Richard E Maine)
- Date: Tue, 31 Jan 2006 11:51:25 -0800
artheartscience <steve@xxxxxxxxxxxxxxx> wrote:
> in my READ statement I
> supplied the END=13 which means "if the user just presses enter, goto
> line 13".
First, no. It does not mean anything close to that. The end= detects an
end-of file. Pressing the enter key does not generate and end of file.
It just generates a record - an empty one, but still a record. You won't
"normally" see an end-of-file on an interactive terminal, because there
is always the possibility that the user will type more input. On a unix
system, control-D will typically generate an interactive end-of-file,
but that's not what I'd call "normal".
> That means just proceed as normal...passing the empty string
> to the FA function should work,
I haven't seen the FA function (if it was in a previous post, I didn't
go back and check), but your terminilogy here makes me suspicious. There
is no such thing in f77 as an "empty" string. There can be an empty
record, but not an empty string. There can be a string full of blanks,
but that isn't the same thing as "empty". Quite the opposite, it is
"full"; what it is full of happens to be blanks, but those are perfectly
valid characters.
> READ(*, END=13) str
Two problems with this line. First is the one that the erro rmessage
bitched about. You don't have a format here. A format specification is
*REQUIRED* for a formatted file. You might be intending the * to be the
format specification, but it isn't. The * here is the unit "number" (*
being a special case to denote the standard input unit). You might have
intended
read(*,*,end=13) string
but that has another problem, namely that list-directed formatting (the
*) is a poor choice here. It will keep "searching" until it finds a line
with some input on it, which is not at all the behavior you want. You
probably want something more like
read(*,'(a)') string
where I have also taken off the end=, which is pretty useless here
unless you really did want to detect control-D.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.
- Follow-Ups:
- Re: Fortran 77: Reading empty string
- From: artheartscience
- Re: Fortran 77: Reading empty string
- References:
- Fortran 77: Reading empty string
- From: artheartscience
- Fortran 77: Reading empty string
- Prev by Date: Re: Need clarification on unformatted IO
- Next by Date: Re: Need clarification on unformatted IO
- Previous by thread: Re: Fortran 77: Reading empty string
- Next by thread: Re: Fortran 77: Reading empty string
- Index(es):