{Használat a Page Up és Page Down billentyûkkel}
Uses
Crt, Dos;
Procedure ViewTextFile(fname: String);
Const
Bad = #255;
Null = #0;
ESC = #27;
Home = #71;
PgUp = #73;
PgDn = #81;
Done : Boolean = False;
PageIndex: Word = 1;
Var
InFile : File;
PFile : Pointer;
Size,
Result,
FileSeg,
off: Word;
Pages: Array[1..2000] of Word;
ch: Char;
begin
Assign(InFile, fname);
{$I-} Reset(InFile, 1); {$I+}
if IOResult <> 0 then
begin
Writeln('File not found: ',fname);
Halt(1)
end;
Size := FileSize(InFile);
GetMem(PFile, Size);
FileSeg := Seg(PFile^);
BlockRead(InFile, PFile^, Size, Result);
FillChar(Pages, SizeOf(Pages), 0);
Repeat
ClrScr;
off := Pages[PageIndex];
Repeat
Write(Chr(Mem[FileSeg:off]));
inc(off);
Until (off = Size) or (WhereY = 25);
Repeat
ch := ReadKey;
if ch = ESC then
Done := True
else
if ch = Null then
Case ReadKey of
Home: PageIndex := 1;
PgUp: if PageIndex > 1 then
Dec(PageIndex);
PgDn: if off < Size then
begin
Inc(PageIndex);
Pages[PageIndex] := off;
end
else
ch := Bad
end;
Until (ch = Null) or Done;
Until Done;
Close(InFile)
end;
begin
if ParamCount > 0 then
ViewTextFile(ParamStr(1))
else
Writeln('Error: Missing File parameter.')
end.