-
Notifications
You must be signed in to change notification settings - Fork 8
/
SCROLLER.PAS
84 lines (74 loc) · 1.65 KB
/
SCROLLER.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
unit Scroller;
interface
uses
Crt, Win;
procedure ScrollText( var Text ; count : integer );
implementation
type
SuperArray = array[1..500] of string[80];
const
page = 22;
limit = 23;
procedure ScrollText( var Text ; count : integer );
var
lines : SuperArray absolute Text;
top : integer;
ch : byte;
moved : boolean;
procedure Display;
var
i : integer;
begin
for i := 1 to limit do
begin
WriteChar( 1, succ(i), 80, ' ', 2 );
if pred(top) + i <= count
then WriteStr( 1, succ(i), lines[pred(top) + i], 2 );
end;
end;
begin
top := 1;
moved := true;
repeat
if moved
then Display;
ch := byte(readkey);
if ch = 0
then ch := byte(readkey);
moved := true;
case ch of
71:
if top <> 1
then top := 1
else moved := false;
72:
if top > 1
then dec( top )
else moved := false;
73:
if top <> 1
then
if top - page < 1
then top := 1
else dec( top, page )
else moved := false;
79:
if top <> count - limit
then top := count - limit
else moved := false;
80:
if top < count - limit
then inc( top )
else moved := false;
81:
if top <> count - limit
then
if top + page > count - limit
then top := count - limit
else inc( top, page )
else moved := false;
else moved := false;
end;
until ch = 27;
end;
end.