home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / nfpat8.zip / NUMLOCK.C < prev    next >
C/C++ Source or Header  |  1993-07-15  |  2KB  |  92 lines

  1. /*
  2.  * File......: NUMLOCK.C
  3.  * Author....: Ted Means
  4.  * Date......: $Date:   15 Jul 1993 00:08:46  $
  5.  * Revision..: $Revision:   1.3  $
  6.  * Log file..: $Logfile:   C:/nanfor/src/numlock.c_v  $
  7.  * 
  8.  * This function is an original work by Ted Means and is placed in the
  9.  * public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   C:/nanfor/src/numlock.c_v  $
  15.  * 
  16.  *    Rev 1.3   15 Jul 1993 00:08:46   GLENN
  17.  * Changed reference to status_byte in order to make this work in
  18.  * protected mode.
  19.  * 
  20.  *    Rev 1.2   15 Aug 1991 23:08:12   GLENN
  21.  * Forest Belt proofread/edited/cleaned up doc
  22.  * 
  23.  *    Rev 1.1   27 May 1991 14:43:20   GLENN
  24.  * Ted added a parameter to toggle the Numlock on or off.
  25.  * 
  26.  *    Rev 1.0   01 Apr 1991 01:02:50   GLENN
  27.  * Nanforum Toolkit
  28.  * 
  29.  *
  30.  */
  31.  
  32.  
  33.  
  34.  
  35. /*  $DOC$
  36.  *  $FUNCNAME$
  37.  *     FT_NUMLOCK()
  38.  *  $CATEGORY$
  39.  *     Keyboard/Mouse
  40.  *  $ONELINER$
  41.  *     Return status of NumLock key
  42.  *  $SYNTAX$
  43.  *     FT_NUMLOCK( [ <lNewSetting> ] ) -> lCurrentSetting
  44.  *  $ARGUMENTS$
  45.  *     <lNewSetting> is optional and if supplied is the new setting
  46.  *     for the CapLock key.  Specify .T. to turn CapLock on, or .F. to
  47.  *     turn it off.
  48.  *  $RETURNS$
  49.  *     lValue is .T. if NumLock is set, .F. if it isn't set.  The value
  50.  *     returned represents the setting in effect prior to any changes that
  51.  *     might by made by <lNewSetting>.
  52.  *  $DESCRIPTION$
  53.  *     This function is useful if you need to know or set the status of the
  54.  *     NumLock key for some reason.
  55.  *  $EXAMPLES$
  56.  *     IF FT_NUMLOCK()
  57.  *        Qout( "NumLock is active" )
  58.  *     ENDIF
  59.  *
  60.  *   Another one, slightly strange, courtesy of Glenn Scott:
  61.  *
  62.  *
  63.  *       function numBlink()
  64.  *          local lOldNum := ft_numlock()
  65.  *
  66.  *          while inkey( .5 ) != 27
  67.  *             ft_numlock( !ft_numlock() )
  68.  *          end
  69.  *
  70.  *          return ft_numlock( lOldNum )
  71.  *  $SEEALSO$
  72.  *     FT_CAPLOCK() FT_CTRL() FT_PRTSCR() FT_SHIFT() FT_ALT()
  73.  *  $END$
  74.  */
  75.  
  76. #include <extend.h>
  77.  
  78. #define status_byte (*(char *)(0x00400017))
  79.  
  80. CLIPPER FT_NUMLOCK(void)
  81. {
  82.    _retl( (int) (status_byte & 0x20) );
  83.  
  84.    if ( PCOUNT )
  85.       if ( _parl(1) )
  86.          status_byte = (status_byte | 0x20);
  87.       else
  88.          status_byte = (status_byte & 0xDF);
  89.  
  90.    return;
  91. }
  92.