12
Pascal 4.0 User’s Guide
2
Using the same program, but with the
<
operator to redirect input, you can
print the file on the terminal:
Using a File Name as a File Variable
You can also redirect the output by listing the file as a file variable in the
program statement. The Pascal library associates the file variable with a file of
the same name. For example,
copy2.p
lists
data
as the input file variable:
hostname% copy < data
hello, are you listening?
goodbye, I must go now.
program copy2(data, output);
{ This program redirects input. }
var
c: char;
data: text;
begin
reset(data);
while not eof(data) do begin
while not eoln(data) do begin
read(data, c);
write(c)
end;
readln(data);
writeln
end
end. { copy2 }
Содержание SunSoft Pascal 4.0
Страница 14: ...xiv Pascal 4 0 User s Guide ...
Страница 16: ...xvi Pascal 4 0 User s Guide ...
Страница 30: ...6 Pascal 4 0 User s Guide 1 ...
Страница 160: ...136 Pascal 4 0 User s Guide 6 ...
Страница 268: ...244 Pascal 4 0 User s Guide 11 ...
Страница 320: ...296 Pascal 4 0 User s Guide B ...
Страница 331: ...Index 307 ...
Страница 333: ......