[comp.sys.mac.programmer] Readln in THINK Pascal, a bug?

lehvaslaiho@cc.helsinki.fi (02/12/91)

Could someone please explain me what should I do to read from keyboard 
more than one value with more than one readln procedures. I am trying
to write standard Pascal with THINK Pascal 3.01 and every time my program 
encounters the second readln() it reports an error: Unexpected end of file.
With the help of manual I have put an writeln(eof) statements in the program 
and found that it really thinks it has read to the end of the file coming 
from the keyboard. I can not reset my keyboard "file", can I?! An other 
peculiarity is that if I step through the program I do not get the error 
message.

I should be able to run the following example program in any Pascal 
implementation, why not in THINK Pascal? Is this a bug or one of the 
infamous peculiarities of Macintosh OS programming?

program ReadlnTest (input, output);
   var 
	X: integer;
begin
	readln(x);
	readln(x);
end.


Heikki Lehvaslaiho
Cancer Biology Laboratory
Departments of Pathology and Virology
University of Helsinki, FINLAND

siegel@endor.uucp (Rich Siegel) (02/13/91)

In article <1991Feb12.100618.4840@cc.helsinki.fi> lehvaslaiho@cc.helsinki.fi writes:
>Could someone please explain me what should I do to read from keyboard 
>more than one value with more than one readln procedures. I am trying
>to write standard Pascal with THINK Pascal 3.01 and every time my program 
>encounters the second readln() it reports an error: Unexpected end of file.
>With the help of manual I have put an writeln(eof) statements in the program 
>and found that it really thinks it has read to the end of the file coming 
>from the keyboard. I can not reset my keyboard "file", can I?! An other 

	If you type the Enter key while entering your input, EOF will become
true for "input", which is represented by the keyboard. You can reset
input, but it should not be necessary to do so.

R.



 Rich Siegel	Symantec Languages Group  Internet: siegel@endor.harvard.edu

"I was just trying to be subtle. That's my job, isn't it?"

phils@chaos.cs.brandeis.edu (Phil Shapiro) (02/14/91)

If you're getting an "Unexpected end of File" error in Pascal, it's
probably because you're entering data using the Enter key on the
keypad.  Pascal treats the Enter key as the end of file character.
Use the Return key instead.

	-phil
--
   Phil Shapiro                           Technical Support Analyst
   Language Products Group                     Symantec Corporation
		Internet: phils@chaos.cs.brandeis.edu