Board index » delphi » eof on input from keyboard

eof on input from keyboard

Hello everybody,
I have a book on pascal that says you can terminate the input from the
keyboard in a while-loop by evaluating the result of eof(input). something
like:

While (not eof(input)) do
   read(c)

When I try this, it does not work. Does anybody know how to make eof true
wiht keyboard imput? I don't have the faintest idea.

Thanks,

Martijn

_________________________________________________________
Martijn Brouwer      e.a.m.brouw...@studentP.AutwenteM.nl

Remove the capital letters S P A M from my adress

 

Re:eof on input from keyboard


On 13 Jun 2000 15:45:39 GMT, e.a.m.brouw...@studentP.AutwenteM.nl

Quote
(Martijn Brouwer) wrote:

>When I try this, it does not work. Does anybody know how to make eof true
>wiht keyboard imput? I don't have the faintest idea.

In DOS, Control-Z
In Linux, Control-D

(I included Linux since this is cross-posted to a non-Borland pascal
group, and anyway, Kylix is "just around the corner," so it could
relate <grin>)

Re:eof on input from keyboard


Quote

>>When I try this, it does not work. Does anybody know how to make eof true
>>wiht keyboard imput? I don't have the faintest idea.

>In DOS, Control-Z
>In Linux, Control-D

>(I included Linux since this is cross-posted to a non-Borland pascal
>group, and anyway, Kylix is "just around the corner," so it could
>relate <grin>)

And FPC is there already ;-)

Re:eof on input from keyboard


Quote
> I have a book on pascal that says you can terminate the input from the
> keyboard in a while-loop by evaluating the result of eof(input). something
> like:

> While (not eof(input)) do
>    read(c)

> When I try this, it does not work. Does anybody know how to make eof true
> wiht keyboard imput? I don't have the faintest idea.

   Since you're in a Borland Pascal NG (where we assume you're using
either TP or BP), I wonder why you think you have to use this technique
(for reading keyboard data).  Reading character-by-character from _any_
device is slow and somewhat cumbersome, and TP/BP provide the String data
type which handles many characters with a single Readln statement.  
Although it's not Standard Pascal, the ability to process strings and
test for end of data (some canonical value or an empty string) eliminates
the need to do all you're doing.
   Perhaps you are required to read individual characters and test for
keyboard EOF (which others have provided answers), but I'd suggest you
take advantage of the TP/BP string and data features - it'll make your
life much easier!

Re:eof on input from keyboard


Quote
> I have a book on pascal that says you can terminate the input from the
> keyboard in a while-loop by evaluating the result of eof(input). something
> like:

> While (not eof(input)) do
>    read(c)

> When I try this, it does not work. Does anybody know how to make eof true
> wiht keyboard imput? I don't have the faintest idea.

   Since you're in a Borland Pascal NG (where we assume you're using
either TP or BP), I wonder why you think you have to use this technique
(for reading keyboard data).  Reading character-by-character from _any_
device is slow and somewhat cumbersome, and TP/BP provide the String data
type which handles many characters with a single Readln statement.  
Although it's not Standard Pascal, the ability to process strings and
test for end of data (some canonical value or an empty string) eliminates
the need to do all you're doing.
   Perhaps you are required to read individual characters and test for
keyboard EOF (which others have provided answers), but I'd suggest you
take advantage of the TP/BP string and data features - it'll make your
life much easier!

Other Threads