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

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