Thread View: net.lang.pascal
1 messages
1 total messages
Started by Neil Faiman ~ ZKO2-3/N30 ~ 381-2...
Sun, 02 Sep 1984 21:06
Re: Bug in 4.2 BSD Pascal implementation ???
Author: Neil Faiman ~ ZKO2-3/N30 ~ 381-2...
Date: Sun, 02 Sep 1984 21:06
Date: Sun, 02 Sep 1984 21:06
32 lines
1795 bytes
1795 bytes
/////
> program ReadTest(input,output);
> var C: char;
> begin
> repeat
> while not eoln do begin (* should echo one line of chars *)
> read(C); write(C);
> end;
> readln(C); (* supposed to be required to read past *)
> writeln; (* end-of-line marker, right ??? *)
> until eof;
> end.
>
> This program seems to work fine when you are reading from the
> standard input, but if you redirect input from a file, every other line
> is skipped.
The Pascal procedure to advance to the next line is "Readln", with no
parameter. "Readln(C)" is equivalent to "Read(C); Readln", which in
turn is equivalent to "C:=Input^; Get(Input); Readln(Input)". This
assigns the space character to C (Input^ = ' ' when Eoln(Input) is true).
The Get advances over the end-of-line condition (Get will advance to the
next line, just like Readln, when Eoln is true). And finally, the Readln
advances to the NEXT line. Presto -- you just skipped over an input line.
So, it's not a compiler bug.
-Neil Faiman
USENET: ...{ucbvax,allegra,decvax}!decwrl!dec-rhea!dec-eludom!faiman
ARPA: FAIMAN%ELUDOM.DEC@DECWRL.ARPA
DEC: ELUDOM::FAIMAN
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads