home *** CD-ROM | disk | FTP | other *** search
- program mdp3;
-
- {Program to accompany article in issue #10 of the Pascal NewsLetter. }
- {Author: Mitch Davis, (3:634/384.6) +61-3-890-2062. }
-
- {This program is a demonstration on how you can make a scroller. Use the }
- {+/- keys, and q to quit. This algorithm is used later. }
-
- uses crt;
-
- const ScreenLen = 24;
- LineCount = 100;
- WinTop:integer = 1; {Note MUST be integer}
-
- var loop:byte;
- ch:char;
-
- function Min (a,b:word):word;
-
- {Returns the smaller of the two parameters}
-
- begin
- if a < b then Min := a else Min := b;
- end;
-
- begin
- {Draw the initial screen}
- gotoxy (1,1);
- for loop := 1 to min (ScreenLen,LineCount-WinTop+1) do writeln (loop,' ');
- write ('*** Use ''+'' to move forward, ''-'' to move back. ''q'' to quit.');
- {do the scrolling}
- repeat
- ch := readkey;
- case ch of
- '-':if WinTop > 1 then begin
- dec (WinTop);
- gotoxy (1,ScreenLen); {bottom of the screen}
- DelLine;
- gotoxy (1,1); {top of the screen}
- InsLine;
- write (WinTop); {the new line}
- end;
- '+':if WinTop < LineCount-ScreenLen+1 then begin
- inc (WinTop);
- gotoxy (1,1); {top of the screen}
- DelLine;
- gotoxy (1,ScreenLen); {bottom of the screen}
- InsLine;
- write (WinTop+ScreenLen-1); {the new line}
- end;
- 'q':; {ensure that it doesn't beep if q is pressed.}
- else write (#7); {beep}
- end;
- until ch = 'q';
- end.
-