home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / lankey2.zip / LANKEYC.C < prev    next >
Text File  |  1993-06-09  |  2KB  |  67 lines

  1. /* LANKEYC.C - extended C language routines for use with Clipper programs
  2.  
  3.   contains : C_INKEY()    - time-slice function called by P_INKEY()
  4.              C_PEEK()     - classic PEEK function
  5.  
  6.   requires Microsoft C Compiler 5.1
  7.  
  8.   compile command:  CL /c /AL /Zl /FPa /Gs lankeyc.c
  9.  
  10.   author: Shawn B. Lipscomb, Intelligent Decisions, Inc.
  11. */
  12.  
  13.  
  14. #include "extend.h"
  15. #include "stdlib.h"
  16. #include "math.h"
  17. #include "bios.h"
  18.  
  19.  
  20. CLIPPER c_inkey()
  21. /*
  22.   Time-slice function called by P_INKEY() that allows a non-dedicated network
  23.   server time to print part of a spooled print job.  There are better ways to
  24.   sense when half a second has passed, but this method has proven to provide
  25.   the maximum benefit to the network spooler.
  26.   Syntax : C_INKEY(nKeybdTailPtr)
  27. */
  28. {
  29.   int mMidnight,pTailPos;
  30.   int far *KeybdBuffTail;
  31.   long mTimesUp,mTimeIs;
  32.  
  33.   pTailPos=_parni(1);
  34.  
  35.   /* create pointer to location of pointer to keyboard buffer tail */
  36.   KeybdBuffTail=(int far *) 0x00400000;
  37.   KeybdBuffTail+=0x1C;
  38.  
  39.   _bios_timeofday(_TIME_GETCLOCK,&mTimesUp);
  40.   mTimesUp+=9;      /* 18.2 ticks/second, and I want to wait half a second */
  41.   mTimeIs=0L;
  42.   mMidnight=0;
  43.  
  44.   while (!kbhit() && (*KeybdBuffTail == pTailPos) && (mTimeIs < mTimesUp) && (! mMidnight))
  45.     mMidnight=_bios_timeofday(_TIME_GETCLOCK,&mTimeIs);
  46.  
  47.   _ret();
  48. }
  49.  
  50.  
  51. CLIPPER c_peek()
  52. /*
  53.   Classic Peek function, restricted to segment 0400.
  54.   Called by P_INKEY() that gets the pointer to the keyboard buffer which
  55.   will later get passed onto c_inkey
  56.   Syntax : C_PEEK(nOffset) => nValue
  57. */
  58. {
  59.   int pOffset;
  60.   int far *mPointer;
  61.  
  62.   pOffset=_parni(1);
  63.   mPointer=(int far *) 0x00400000;
  64.   mPointer+=pOffset;
  65.   _retni(*mPointer);
  66. }
  67.