Bob,

I never use eoln so I am unsure. However, having taught myself Pascal from Wirths original manual, my gut feeling is that D8 is wrong.

[EMAIL PROTECTED] wrote:

Hi all

The console application below behaves differently in D8 from D7/D5. In D8 the first loop only is executed, in D7/D5 both loops are executed. I use console applications to start my students off, and in the past I've always unthinkingly used statements like: -

while not Eoln do
read(Ch);
readln;


- until this year when using D8. Of course its easy to get around by using a repeat .. until eoln statement but it occurred to me that perhaps in pure Pascal both of the while loops would not execute, because Eoln should be false until the readln statement pauses execution waiting for a CR/LF.

Thoughts/comments anyone.

Bob Osborn

Code follows:


program Project2; {$APPTYPE CONSOLE} var ch: char; s1: string; begin s1 := ''; while not eoln do begin read(ch); s1 := s1 + ch; end; readln;

 while not eoln do
 begin
   read(ch);
   s1 := s1 + ch;
 end;
 readln;

writeln(s1);

 readln;  // pause the console screen
end.





_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to