home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / keyboard / numlock / numlock.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1994-04-30  |  2.3 KB  |  80 lines

  1. {$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R+,S+,T-,V-,X+,Y+}
  2. (* Corrected and adapted to BP7 jb/'94 *)
  3.  
  4. PROGRAM NumLock;
  5. {**************************************************************************
  6.  * * *  NumLock, by Mark Rostek, P.O. Box 158, Garfield, NJ 07026  *  *  *
  7.  
  8.   The two procedures presented here will allow your own programs
  9.   to set and clear the bit controlling the NumLock key at absolute
  10.   address $0000:$0417.
  11.  
  12.   When this bit is set the number keypad will be active.
  13.  
  14.   NumLock will demonstrate the use of the two procedures "NumOn" and
  15.   "NumOff."  For the purposs of clarity, there is some redundency in the
  16.   code.
  17.  
  18.   To use these two procedures just include them in your program and make
  19.   appropriate calls when you wish to use the number keypad.
  20.  
  21. **************************************************************************}
  22. USES
  23.   Crt;
  24.  
  25. CONST
  26.    bit_position =  5;                  {bit controlling NumLock}
  27.  
  28. VAR
  29.    SetBit:        byte   Absolute $0040:$0017;
  30.    Mask:          byte;
  31.  
  32. PROCEDURE NumOn;
  33. {*************************************************************************
  34.      Sets the NumLock key
  35.  ************************************************************************}
  36. CONST
  37.    bit_position =  5;                  {bit controlling NumLock}
  38.  
  39. VAR
  40.    SetBit:        byte   Absolute $0040:$0017;
  41.    Mask:          byte;
  42.  
  43. BEGIN
  44.    Mask := 1 SHL  bit_position;
  45.    SetBit := SetBit OR Mask            {sets the bit}
  46.  
  47. END;   {PROCEDURE NumOn}
  48. {═════════════════════════════════════════════════════════════════════════}
  49.  
  50. PROCEDURE NumOff;
  51. {*************************************************************************
  52.      Clears "Num Lock"  key
  53.  ************************************************************************}
  54. CONST
  55.    bit_position =  5;
  56.  
  57. VAR
  58.    SetBit:        byte   Absolute $0040:$0017;
  59.    Mask:          byte;
  60.  
  61. BEGIN
  62.    Mask := 1 SHL bit_position;
  63.    Mask := NOT Mask;
  64.    SetBit := SetBit AND Mask           {clears the bit}
  65.  
  66. END;   {PROCEDURE NumOff}
  67. {═════════════════════════════════════════════════════════════════════════}
  68.  
  69. BEGIN   {main}
  70.    clrscr;
  71.    NumOn;
  72.    writeln('The keypad is now active.  Use it to enter a number.');
  73.    readln;
  74.    writeln;
  75.    writeln;
  76.    NumOff;
  77.    writeln('The keypad is off.  Try it now.');
  78.    readln
  79. END.   {PROGRAM NumLock}
  80.