From: e p chandler on

"Richard Maine" <nospam(a)see.signature> wrote in message
news:1jlx7qi.1ro1r80ymojmsN%nospam(a)see.signature...
>e p chandler <epc8(a)juno.com> wrote:
>
>> "Alois Steindl" <Alois.Steindl(a)tuwien.ac.at> wrote in message
>> news:m3d3uiur90.fsf(a)mch2pc28.mechanik.tuwien.ac.at...
>> > "e p chandler" <epc8(a)juno.com> writes:
>> >
>> >> What is list directed formatting supposed to do when it encounters an
>> >> empty field?
>> >
>> > It seems, that on reading it doesn't change the variable at all,
>
>> Ouch. This reminds me of BASIC on the Commodore 64. It left the previous
>> contents of a variable when given an empty input. This was a real pain
>> when I wanted to be able to have the user input an empty string, say to
>> exit a loop or go back to the previous menu. There I had to
>> pre-initialize
>> the variable to empty before each input statement.
>
> Two things.
>
> 1. To input an empty string, quote it. That's generally the way to
> handle most problems with special input strings.

OK. Actually I'm dealing with input from a data file. I wrote a small
program just to test the feature that I did not understand.

> 2. List-directed input is handily simple, but correspondingly limitted
> in flexibility.
[snip]

> 3. If you want the user to be able to just hit return to indicate
> something special (a common enough requirement), then you have more
> serious problems than the treatment of empty fields.

That was just a historical comment. As you suggested I would have read the
input into a
character buffer first.

> P.S. This stuff is all from f77, when list-directed input was introduced
> to the standard, so it isn't particularly new. Before f90, list-directed
> internal I/O was nonstandard and did not work in all compilers, which
> made some of the alternatives awkward. By around the time f90 came out,
> it also worked in most f77 compilers.

Fortran 77 is still relatively new to me [smile].



From: robin on
"e p chandler" <epc8(a)juno.com> wrote in message news:i24dhj$872$1(a)news.eternal-september.org...

| What is list directed formatting supposed to do when it encounters an empty
| field?

It leaves the variable alone.
Same thing if the input record contains two or more consecutive commas.


From: robin on
"e p chandler" <epc8(a)juno.com> wrote in message news:i24fbk$j9f$1(a)news.eternal-september.org...
|
| "Alois Steindl" <Alois.Steindl(a)tuwien.ac.at> wrote in message
| news:m3d3uiur90.fsf(a)mch2pc28.mechanik.tuwien.ac.at...
| > "e p chandler" <epc8(a)juno.com> writes:
| >
| >> What is list directed formatting supposed to do when it encounters an
| >> empty
| >> field?
| >
| > It seems, that on reading it doesn't change the variable at all, so if
| > it contained some garbage before, that garbage remains in its place.
| > Alois
|
| Ouch. This reminds me of BASIC on the Commodore 64. It left the previous
| contents of a variable when given an empty input. This was a real pain when
| I wanted to be able to have the user input an empty string,

Try '' [two consecutive apostrophes]

| say to exit a
| loop or go back to the previous menu. There I had to pre-initialize the
| variable to empty before each input statement.