In Turbo Pascal the function [b]eof[/b] is TRUE if, and only if, the [b]next[/b] character to be read is the end-of-file character, videlicet, [b]chr(26)[/b]. Reading the file when eof is TRUE will return chr(26).
[b]eoln[/b] is TRUE if the next character to be read is a carriage return [b]chr(13)[/b] OR the end-of-file character. Reading the file when eoln is TRUE will return chr(13) or chr(26), as the case may be.
The normal Pascal practice is to test before you read, e.g.,
while not eof do begin
while not eoln do begin
read (ch) ;
do something with ch
This implies that Turbo Pascal can look ahead at least one character before actually reading it. There must be a buffer between the keyboard (or disk or whatever) that holds at least one character and Turbo Pascal can read it.
Sometimes a situation arises where it would be nice to look ahead by one character before reading it. For example...
read (ch) ;
if (ch = '(') and (NextChar = '*') then
InComment := TRUE ;
In the original incarnation of Pascal the procedure [b]get[/b] could be used to look ahead one character but get is not part of Turbo Pascal. Is there any other way to implement [b]NextChar[/b]?