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 >
Pascal/Delphi Source File  |  1993-01-14  |  1KB  |  37 lines

  1. Program KeyCheck;
  2.  
  3. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  4. { This program illustrates the use of Units in Turbo Pascal, whereby   }
  5. { compiled code can be incorporated into the current program. The unit }
  6. { is called LIMITKEY.TPU and provides a procedure that only allows a   }
  7. { selected set of keys to be acceptable input. The selected keys are   }
  8. { defined as the first parameter of the procedure LimitChar.           }
  9. { Based on a program by David Arber of David Arber Associates.         }
  10. {                                                                      }
  11. { KEYCHECK.PAS  ->  .EXE       R Shaw         3.12.92                  }
  12. {______________________________________________________________________}
  13.  
  14. Uses Crt, LimitKey;
  15.  
  16. Var
  17.   Ch    : char;
  18.   XKey  : boolean;
  19.  
  20. begin
  21.    ClrScr;
  22.    writeln;
  23.    writeln('Please press a number key 1 - 7 to change foreground color or Q to quit');
  24.    repeat
  25.       repeat
  26.         LimitChar('1234567Qq',Ch,XKey);
  27.       until not XKey;
  28.       if UpCase(ch) <> 'Q' then
  29.         begin
  30.            TextColor(integer(Ch)-48);
  31.            writeln('This text is now displayed in foreground colour ',Ch);
  32.            writeln;
  33.            writeln('Please press a number key 1 - 7 to change foreground color again or Q to quit');
  34.         end;
  35.    until UpCase(Ch) = 'Q';
  36.    TextColor(15);
  37. end.