eof on input from keyboard 
Author Message
 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

_________________________________________________________

Remove the capital letters S P A M from my adress



Wed, 18 Jun 1902 08:00:00 GMT  
 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>)



Wed, 18 Jun 1902 08:00:00 GMT  
 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 ;-)


Wed, 18 Jun 1902 08:00:00 GMT  
 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!


Wed, 18 Jun 1902 08:00:00 GMT  
 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!


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. eof on input from keyboard

2. keyboard input

3. Raw keyboard input...

4. And another thing - keyboard input

5. runtime fields (for input by keyboard)

6. Keyboard Input

7. Help requested: keyboard input..

8. keyboard-input

9. FindKey kills keyboard input ?

10. problem with ADODataSet.EOF

11. Delete & EOF on detail tables

12. EOF returns true before accessed last record (Delphi 1)

 

 
Powered by phpBB® Forum Software