HP Pascal/iX Programmer's Guide (31502-90023)

3-: 17
rewrite(out); {Open out for textfile output}
readln(in,x,y,z); {Read x, y, and z from in}
write(out,x); {Write x to out}
overprint(out); {Write buffer and line-feed suppression to out}
writeln(out,y); {Write y to out and advance to next line}
page(out); {Write page-eject character to out}
writeln(out,z); {Write z to out and advance to next line}
prompt(out,'?'); {Write '?' to out, without carriage control}
readln(in,w); {Read user's answer to '?' from in}
writeln(out,w); {Write user's answer to out}
END.
When a device prints the file
out,
it prints the value of y over the
value of x, and it prints the values of z and w on the next page.
Table 3-7 summarizes the characteristics of the predefined textfile
functions.
Table 3-7. Characteristics of Textfile Functions
------------------------------------------------------------------------------------------------
||| |
| Function |
Eoln
|
Linepos
|
||| |
------------------------------------------------------------------------------------------------
|||||
| State that file must | Read-only | Read-only | Write-only |
|bein | | | |
|||||
------------------------------------------------------------------------------------------------
|||||
| Returns |
True
if the current | Number of characters | Number of characters |
| | position index is at | read from file since | written to file since |
| | an end-of-line | last end-of-line | last end-of-line |
| | marker;
false
| marker (excluding | marker (excluding |
| | otherwise. | character in buffer). | character in buffer). |
|||||
|||||
| | | After
readln
, or when | After
writeln
,or |
| | | current position | when current position |
| | | index is at | index is at |
| | | end-of-line marker, | end-of-line marker, |
| | | this number is zero. | this number is zero. |
|||||
------------------------------------------------------------------------------------------------
||| |
| Effect on buffer | If
eoln
returns
true
,| None |
| | it assigns a blank | |
| | character to the | |
| | buffer | |
||| |
------------------------------------------------------------------------------------------------
Example 2
PROGRAM prog (infile,outfile,output);
VAR
infile,
outfile : text;
i : integer;
c : char;
BEGIN
reset(infile); {Open infile for input}
rewrite(outfile); {Open outfile for output}
WHILE not(eof(infile)) DO BEGIN {If infile is not at end-of-file}
IF eoln(infile) THEN BEGIN {but the current line of in has ended,}
writeln(linepos(infile)); {print the number of characters read
from the current line of infile,}