home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / NUMLOCK.ZIP / NUMLOCK.PAS
Encoding:
Pascal/Delphi Source File  |  1986-08-19  |  2.3 KB  |  73 lines

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