home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
GLEN
/
VOL10N22.ZIP
/
STATIC2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-11-25
|
3KB
|
103 lines
STATIC2.PAS
COMPLETE LISTING
PROGRAM Static2;
USES Crt;
VAR TickCount : LongInt ABSOLUTE $40:$6C;
CONST
TypeStr : ARRAY[1..3] OF String[73] =
('The quick brown fox jumped over the lazy dog.',
'Pack my box with five dozen liquor jugs.',
'Now is the time for all good persons '+
'to come to the aid of their country.');
TimeFactor = 2;
PROCEDURE TickTock;
CONST TickWas : LongInt = 0;
High : Boolean = TRUE;
BEGIN
IF TickCount >= TickWas + 9 THEN
BEGIN
IF High THEN Sound(1200) ELSE Sound(600);
High := NOT High;
TickWas := TickCount;
END
ELSE IF TickCount > TickWas THEN NoSound;
END;
PROCEDURE UpdateXY(VAR X, Y : Byte; Len : Byte);
BEGIN
Inc(X);
IF X > Len THEN
BEGIN
X := 1;
Inc(Y, 2);
END;
END;
PROCEDURE TestString;
CONST X : Byte = 1;
Y : Byte = 1;
TickWas : LongInt = 0;
BEGIN
IF TickCount > TickWas + TimeFactor THEN
BEGIN
GotoXY(X, Y); Write(TypeStr[Succ(Y) DIV 2][X]);
UpdateXY(X, Y, Length(TypeStr[Succ(Y) DIV 2]));
IF Y > 5 THEN
BEGIN
GotoXY(1,24);
WriteLn('Sorry, you did not pass.');
NoSound; Halt;
END;
TickWas := TickCount;
END;
END;
PROCEDURE YouType;
CONST X : Byte = 1;
Y : Byte = 2;
Errors : Word = 0;
VAR C : Char;
Hold : Byte;
BEGIN
IF KeyPressed THEN
BEGIN
C := ReadKey;
IF C = #27 THEN BEGIN NoSound; Halt; END;
IF C = TypeStr[Y DIV 2][X] THEN
BEGIN
Hold := TextAttr; TextAttr := $0F;
GotoXY(X, Y); Write(C,' ');
UpdateXY(X, Y, Length(TypeStr[Y DIV 2]));
GotoXY(X, Y); Write(#219);
TextAttr := Hold;
IF Y > 6 THEN
BEGIN
GotoXY(1,24);
WriteLn('You passed with ',Errors,' errors.');
NoSound; Halt;
END;
END
ELSE Inc(Errors);
END;
END;
BEGIN
TextAttr := $07; ClrScr; GotoXY(1,25);
Write('TYPING TEST! Three lines...');
GotoXY(1,1); Write(TypeStr[1]);
GotoXY(1,3); Write(TypeStr[2]);
GotoXY(1,5); Write(TypeStr[3]);
TextAttr := $0F; GotoXY(1,2); Write(#219);
TextAttr := $70;
REPEAT
TickTock;
TestString;
YouType;
UNTIL FALSE;
END.