home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / FOXPRO / TASKDE / TASKDEMO.DOC < prev    next >
Text File  |  1993-12-26  |  5KB  |  141 lines

  1. TASKDEMO.DOC
  2.  
  3. DECEMBER 28,1993
  4.  
  5.     The TASKDEMO.PRG program uses a FoxPro binary file called INTERVAL.BIN
  6. to stuff the Keyboard buffer at any interval you specify. INTERVAL.BIN is
  7. based on TIMEOUT.BIN by Paul Saffren. TIMEOUT.BIN is available on
  8. Compuserve. INTERVAL.BIN can be used as a one shot timer like TIMEOUT.BIN
  9. or as a continuous interval timer. TASKDEMO.PRG is an extreme example of
  10. using the interval timer to simulate a multi-tasking environment in FoxPro.
  11. A more usual application of the interval timer would be to check for some
  12. condition every 10 minutes or so. e.g - See if a file has arrived in a
  13. network directory or seek on a shared database file. Unfortunately there
  14. are severe limitations on what can be done while using the interval timer.
  15. The usefulness of the interval timer depends on the application involved and
  16. the type of activity that is going on in the foreground. In the case of
  17. the TASKDEMO.PRG many hoops must be jumped through.
  18.  
  19.     The main problem is that when you are editing a GET field and execute
  20. a user defined function by pressing an 'ON KEY LABEL' key and return
  21. to editing, the cursor has returned to the beginning of the field. Since you
  22. don't know when the interval timer is going to stuff the key and call your
  23. UDF you may be right in the middle of editing a field when the cursor returns to the begining of the field. This is not a large problem if the
  24. interval is a long one e.g. - 5,10,15 minutes. The TASKDEMO program gets
  25. around this problem by useing EDIT fields instead of GET fields. EDIT fields
  26. maintain the cursor possition during UDF calls. But! it seems that with
  27. single line EDIT fields the cursor position is not maintained if the
  28. character to the left of the cursor is a Space (32) character. TASKDEMO
  29. gets around this by using ASCII (255) characters instead of space characters
  30. while editing a field and then replaces them with spaces on exiting the
  31. field. (Kludge, but it seems to work)
  32.  
  33.     Like I said, TASKDEMO is an extreme example in that it allows the
  34. user to type away while fields are updating and windows are opening and
  35. closing in the background. In a more typical application there may be
  36. no reason not to turn off the timer while the user edits a field. If you
  37. are not actually editing a text type GET field there seems to be no
  38. problems running the timer at a high interval e.g. 1 second. The AMOUNT
  39. field in the demo is a regular Numeric GET field. The Timer is turned
  40. off by the field's WHEN clause and restarted by the VALID clause.
  41.  
  42.     I didn't use FoxPro Button controls because I think the psuedo Buttons
  43. work cleaner, but regular buttons will work no problem with the interval
  44. timer. (The Confirm Quit window uses regular buttons).
  45. Actually it seems you can edit records in a BROWSE or a CHANGE screen
  46. with no adverse effects when using the interval timer. You just have to
  47. ACTIVATE the browse window with the last statement of your UDF if you are
  48. doing output to a diffent window.
  49.  
  50. DETAILS ON USING INTERVAL.BIN
  51.  
  52.     INTERVAL.BIN is a modified version of TIMEOUT.BIN by Paul Saffren.
  53. Paul has released TIMEOUT to the public domain and INTERVAL.BIN is also
  54. public domain. INTERVAL.BIN was assembled with Turbo Assembler 3.2
  55.  
  56. To use INTERVAL.BIN in a program include the following in the setup code
  57. of your program.
  58.  
  59.   LOAD INTERVAL.BIN
  60.  
  61. To start the timer:
  62.  
  63.   CALL INTERVAL WITH '182,126'
  64.  
  65.   The parameters must be given as a single string. In the case above
  66.   INTERVAL will stuff the keyboard with the tilde character '~' every
  67.   10 seconds. The first half of the parameter (182) is the number of
  68.   timmer ticks to count before stuffing the key. The PC's timer ticks
  69.   18.2 times a second. 18.2 x 10 is 182, exactly 10 seconds. 91 would
  70.   be exactly 5 seconds. Do not pass decimal numbers like 18.2 for exactly
  71.   1 second, use 18 or 19. Integers only.
  72.   The second part of the parameter is the decimal ASCII code for the
  73.   key you want to stuff between 0 and 255. If you do not specify a key
  74.   the default is 27 (Escape). e.g. - CALL INTERVAL WITH '182'
  75.  
  76. To call your timer routine:
  77.  
  78.   ON KEY LABEL ~ DO MyTimerRoutine
  79.  
  80.   I like to use the tilde ~ character because it is seldom used.
  81.  
  82. A sample timer routine:
  83.  
  84.   PROCEDURE MyTimerRoutine
  85.     DO This
  86.     DO That
  87.     DO OtherThing
  88.   RETURN
  89.  
  90. To stop the timer:
  91.  
  92.   CALL INTERVAL WITH '0'
  93.  
  94.   Note: You MUST make this call before exiting your program.
  95.  
  96.  
  97. To Unload INTERVAL from Memory:
  98.  
  99.   RELEASE MODULE INTERVAL
  100.  
  101.  
  102. Example program shell:
  103.  
  104.   LOAD INTERVAL.BIN
  105.   ON KEY LABEL ~ DO MyTimerRoutine
  106.   CALL INTERVAL WITH '182,126'
  107.  
  108.   DO DefineMyGets
  109.   READ
  110.  
  111.   ON KEY LABEL ~
  112.   CALL INTERVAL WITH '0'
  113.   RELEASE MODULE INTERVAL
  114.  
  115.  
  116. Example of a one shot timer:
  117.  
  118.   LOAD INTERVAL.BIN
  119.   ON KEY LABEL ~ DO MyTimerRoutine
  120.   CALL INTERVAL WITH '182,126'
  121.  
  122.   DO DefineMyGets
  123.   READ
  124.  
  125.   ON KEY LABEL ~
  126.   CALL INTERVAL WITH '0'
  127.   RELEASE MODULE INTERVAL
  128.  
  129.  
  130.   PROCEDURE MyTimerRoutine
  131.     CALL INTERVAL WITH '0'
  132.     DO Something
  133.   RETURN
  134.  
  135.   IF your program is going to be performing a lengthy operation e.g. -
  136. run a report or doing a LOCATE on a large file remember to stop the
  137. timmer until the procedure returns.
  138.  
  139.  
  140. Ed Duchesne
  141.