Hi there,
I've written a TP 6.0 program to scroll text up and down, but it does not
look very professional. How can I improve it? (maybe make it move smoother)
Thanks in advance.
Johan Kohler
johan.koh...@als.co.za
-----------------------CUT HERE----------------------------------
Program TeksScroll;
Uses Graph, Crt;
Var Skik : Array[1..100] of String;
f : text;
i, j, gd, gm : integer;
line : string;
oldn, n : integer;
ch : char;
{Number of lines displayed = 22}
{use Up and Down arrow keys to scroll}
Begin
n := 1;
gd := detect;
InitGraph(gd, gm, '');
Randomize;
SetColor(Blue);
Rectangle(1, 1, 600, 300);
Assign(f, '{Put the name of a text file here}');
Reset(f);
For i := 1 to 100 do
Readln(f, Skik[i]);
Close(F);
SetTextStyle(SmallFont, HorizDir, 5);
SetColor(White);
For i := n to 22 do
Begin
line := Skik[i];
OutTextXY(10, i * 12, line);
End;
Repeat
ch := ' ';
If keypressed then ch := Readkey;
Case Upcase(ch) of
{Decide whether up or down was pressed and act accordingly}
#80 : If n < 22 then Begin oldn := n; inc(n); ch := '*'; End;
#72 : If n > 1 then Begin oldn := n; dec(n); ch := '*'; End;
Else ch := ' ';
End;
If ch = '*' then
Begin
If n > oldn then
Begin
j := 22;
SetColor(Black);
For i := 22 + oldn - 1 downto oldn do
Begin
line := Skik[i];
OutTextXY(10, j * 12, line);
dec(j);
End;
j := 22;
SetColor(White);
For i := 22 + n - 1 downto n do
Begin
line := Skik[i];
OutTextXY(10, j * 12, line);
dec(j);
End;
End
Else
Begin
j := 0;
SetColor(Black);
For i := oldn to 22 + oldn - 1 do
Begin
inc(j);
line := Skik[i];
OutTextXY(10, j * 12, line);
End;
j := 0;
SetColor(White);
For i := n to 22 + n - 1 do
Begin
inc(j);
line := Skik[i];
OutTextXY(10, j * 12, line);
End;
End;
End;
Until ch = #27;
End.
___ Blue Wave/DOS v2.30 [NR]