home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / xbase / library / clipper / timer / ontick / ontick.doc next >
Encoding:
Text File  |  1992-05-12  |  3.2 KB  |  73 lines

  1.  
  2.  
  3.     I have, on occasion, wondered how you would attach a Clipper function
  4. to the system clock for periodic evaluation ( Usually when I had an urgent
  5. need to do so). With the aid of a few books ( namely Undoccumented DOS and
  6. the DOS Programmer's Reference) and a friend of mine for help with the
  7. Assembly routines an attempt was made, the results of which is in your hands.
  8. I should point out that this routine was written by me in attempt to get
  9. aquainted with C interrupts and that there are other routines out there that
  10. may work for you with less hassel -- namely NetLib's N_SETTIME().
  11.  
  12. Initially the ticker routine actually called the udf from within the
  13. int 8 handler.  While this seemed to work on the surface, it was not a
  14. reliable solution.  Although ticker prevents dos recursion by checking the
  15. dos safe flag, Clipper is itself NON RE-ENTRANT.  This being the case there
  16. was no telling when my int 8 routine would hang the system because Clipper
  17. was in the middle of a non re-entrant routine ( such as __PLANKTON).
  18. Unfortunately Clipper doesn't to my knowledge have a ClipperSafe flag.  The
  19. workaround to this was to find a way to get CLIPPER TO CALL THE UDF on a
  20. periodic basis for me.  I accomplished this by setting up a hotkey to the udf
  21. and then, instead of calling the routine myself, stuffing the keyboard buffer
  22. the the hotkey's scan code from within the int 8 routine.  The downshot of
  23. this approach is that it only works while the Clipper wait-state is active.
  24. The upshot is that it doesn't cause you system to barf.  If your routine does
  25. not hit a wait-state periodicly -- you might consider using an inkey()
  26. replacement that is hotkey (wait-state) aware inside your code.
  27.  
  28.  
  29. ONTICK USAGE:
  30. -------------
  31. IT is EXTREMELY important that you remember to shutdown the ontick()
  32. routine BEFORE you terminate your application.  If you don't you are
  33. guaranteed to force yourself into a re-boot situation.  You might want 
  34. to put an ontick() call in your error handler so that if you encounter
  35. any fatal runtime errors in your application you won't have to continualy
  36. re-boot your system.
  37.  
  38. DO NOT OVERLAY  onTickC.obj, onTickA.obj
  39.  
  40.  
  41. FILES YOU SHOULD HAVE:
  42. ----------------------
  43. You should have three programs -- ontick.prg, ontickc.c, and onticka.asm.
  44. and the object modules ontickc.obj and onticka.obj.
  45.  
  46. ontick.prg:
  47.     This is the clipper5 module which provides your interface to the
  48.     system timer.  It includes a simple test routine which you can exclude
  49.     from compilation by removing the #define _TEST from the source.
  50.  
  51. ontickC.C:
  52.     C routines which modify the int 8 timer vector and handle the periodic
  53.     servicing of your specified clipper function by way of the keyboard
  54.     buffer.
  55.  
  56. ontickA.Asm:
  57.     Assembler replacements for the Microsoft _dos_setvector() and
  58.     _dos_getvector() routines ( so we don't need LLIBCA to link) and a
  59.     routine to get the address of the dos safe flag.  The new routines are
  60.     called _setvector(), _getvector(), and _getindosAddress().
  61.  
  62.  
  63. I want to thank all those people who helped me with this in one way or
  64. another-  Namely Ted Means and John MacDonald.
  65.  
  66. Please let me know what you think.  
  67.  
  68.     Brenton Farmer
  69.     CIS: 71621,627
  70.  
  71.  
  72.  
  73.