home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / SETLASTK.ASM < prev    next >
Assembly Source File  |  1992-07-01  |  3KB  |  83 lines

  1. ;
  2. ; File......: SETLASTK.ASM
  3. ; Author....: Ted Means
  4. ; CIS ID....: 73067,3332
  5. ; Date......: $Date:   01 Jul 1992 01:23:06  $
  6. ; Revision..: $Revision:   1.0  $
  7. ; Log file..: $Logfile:   C:/nanfor/src/setlastk.asv  $
  8. ; This 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/setlastk.asv  $
  15. ;  
  16. ;     Rev 1.0   01 Jul 1992 01:23:06   GLENN
  17. ;  Initial revision.
  18.  
  19. ;  $DOC$
  20. ;  $FUNCNAME$
  21. ;     FT_LASTKEY()
  22. ;  $CATEGORY$
  23. ;     Keyboard/Mouse
  24. ;  $ONELINER$
  25. ;     Force LastKey() to return a programmer-defined value.
  26. ;  $SYNTAX$
  27. ;     FT_LastKey( <nKey> ) -> NIL
  28. ;  $ARGUMENTS$
  29. ;     <nKey> is the Inkey() value of the desired key.
  30. ;  $RETURNS$
  31. ;     NIL
  32. ;  $DESCRIPTION$
  33. ;     It is occasionally useful to force LastKey() to return a known value.
  34. ;     This is easily accomplishing by using the KEYBOARD command, but this
  35. ;     has undesireable side effects (the keyboard buffer is cleared, and
  36. ;     the keystroke is processed whether you needed it to be or not).  This
  37. ;     function accomplishes the same task but without the side effects.  It
  38. ;     does so by directly modifying the memory location where Clipper stores
  39. ;     the LastKey() value.
  40. ;
  41. ;     Some highly unorthodox programming techniques, not to mention rather
  42. ;     strange use of Clipper internals, was necessary to make this function
  43. ;     work.  If this makes you uncomfortable, then don't use this function,
  44. ;     you worthless crybaby.
  45. ;  $EXAMPLES$
  46. ;     keyboard chr( K_ESC )
  47. ;
  48. ;     ? lastkey()  // returns 27
  49. ;
  50. ;     FT_LastKey( K_F1 )
  51. ;
  52. ;     ? lastkey()  // now returns 28
  53. ;  $END$
  54. ;
  55.  
  56. Public   FT_LastKey
  57.  
  58. Extrn    LastKey:Far
  59. Extrn    __ParNL:Far
  60.  
  61. Segment  _NanFor   Word      "CODE"
  62.          Assume    CS:_NanFor
  63.  
  64. Proc     FT_LastKey          Far
  65.  
  66.          Mov       AX,1                      ; Specify param #1
  67.          Push      AX                        ; Put on stack
  68.          Call      __ParNL                   ; Get key value
  69.          Add       SP,2                      ; Realign stack
  70.  
  71.          Mov       CX,Seg LastKey            ; Load segment of known symbol
  72.          Mov       BX,Offset LastKey         ; Load offset of known symbol
  73.          Mov       ES,CX                     ; Load segment register
  74.          Mov       BX,[Word Ptr ES:BX + 8]   ; Get address
  75.          Mov       [Word Ptr BX],AX          ; Store key value
  76.          Mov       [Word Ptr BX + 2],DX
  77.          Ret
  78. Endp     FT_LastKey
  79. Ends     _NanFor
  80. End
  81.