home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / gt_inkey.prg < prev    next >
Text File  |  1993-10-14  |  2KB  |  77 lines

  1. /*
  2.  * GT CLIPPER STANDARD HEADER
  3.  *
  4.  * File......: gt_inkey.prg
  5.  * Author....: Andy M Leighton
  6.  * BBS.......: The Dark Knight Returns
  7.  * Net/Node..: 050/069
  8.  * User Name.: Andy Leighton
  9.  * Date......: 23/05/92
  10.  * Revision..: 1.00
  11.  *
  12.  * This is an original work by Andy Leighton and is placed in the
  13.  * public domain.
  14.  *
  15.  * Modification history:
  16.  * ---------------------
  17.  *
  18.  * $Log$
  19.  *
  20.  */
  21.  
  22. /*  $DOC$
  23.  *  $FUNCNAME$
  24.  *       GT_INKEY()
  25.  *  $CATEGORY$
  26.  *       Keyboard
  27.  *  $ONELINER$
  28.  *       Modified inkey() that calls setkey procedures
  29.  *  $SYNTAX$
  30.  *       GT_INKEY(<nWait>) --> nKey
  31.  *  $ARGUMENTS$
  32.  *       <nWait>  - how long to wait
  33.  *  $RETURNS$
  34.  *       nKey     - a modified INKEY() value
  35.  *  $DESCRIPTION$
  36.  *       Performs an inkey() and if there is an action block assigned
  37.  *       to that key, it will evaluate the block and then negate the
  38.  *       inkey() value.
  39.  *
  40.  *       Returning a negative value for those keys that have had a
  41.  *       set key block assigned is a little different to the way
  42.  *       waitkey() works in Funcky but I find this information to
  43.  *       be more useful.
  44.  *  $EXAMPLES$
  45.  *
  46.  *       set key K_F1 to helpme()
  47.  *
  48.  *       nVal := GT_inkey(0)
  49.  *
  50.  *       if nVal < 0
  51.  *          ? "A set key procedure was called"
  52.  *       endif
  53.  *       "Inkey value " + nVal
  54.  *
  55.  *  $END$
  56.  */
  57.  
  58. #include "gt_LIB.ch"
  59.  
  60. function GT_Inkey(nWait)
  61.  
  62.    local nKey
  63.    local bExtra
  64.  
  65.    if nWait == NIL
  66.       nKey := inkey()
  67.    else
  68.       nKey := inkey(nWait)
  69.    endif
  70.  
  71.    if (bExtra := setkey(nKey)) != NIL
  72.       eval(bExtra, procname(1), procline(1), "")
  73.       nKey := -nKey
  74.    endif
  75.  
  76. return nKey
  77.