home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PASTUT34
/
KEYCHECK.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-01-14
|
1KB
|
37 lines
Program KeyCheck;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
{ This program illustrates the use of Units in Turbo Pascal, whereby }
{ compiled code can be incorporated into the current program. The unit }
{ is called LIMITKEY.TPU and provides a procedure that only allows a }
{ selected set of keys to be acceptable input. The selected keys are }
{ defined as the first parameter of the procedure LimitChar. }
{ Based on a program by David Arber of David Arber Associates. }
{ }
{ KEYCHECK.PAS -> .EXE R Shaw 3.12.92 }
{______________________________________________________________________}
Uses Crt, LimitKey;
Var
Ch : char;
XKey : boolean;
begin
ClrScr;
writeln;
writeln('Please press a number key 1 - 7 to change foreground color or Q to quit');
repeat
repeat
LimitChar('1234567Qq',Ch,XKey);
until not XKey;
if UpCase(ch) <> 'Q' then
begin
TextColor(integer(Ch)-48);
writeln('This text is now displayed in foreground colour ',Ch);
writeln;
writeln('Please press a number key 1 - 7 to change foreground color again or Q to quit');
end;
until UpCase(Ch) = 'Q';
TextColor(15);
end.