home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / TIMING2.ZIP / TIMERS.BAS < prev    next >
BASIC Source File  |  1989-09-12  |  3KB  |  74 lines

  1. '$MODULE: 'TIMERS'
  2. '$INCLUDE: 'fnCTICKS.def'
  3. '*** end of DELAY
  4. '*****************************************************************************
  5. '*** end of BGDELAY
  6. '*****************************************************************************
  7.  
  8. REM $DYNAMIC
  9. SUB BGDELAY (HUN.SCNDS!, HUN.SCNDS.TO.GO!, status%) STATIC
  10. '----------------------------------------------------------------------------
  11. ' BigDelay Procedure: Performs a background delay, returning control to the
  12. ' caller after each check so that the caller may be doing something while
  13. ' waiting.
  14. '----------------------------------------------------------------------------
  15. '$MODULE: 'bgDELAY'
  16. ' input:  an integer representing the number of hundredth-seconds to delay
  17. ' delay == input: HUN.SCNDS! = hundredths of seconds
  18. '         output: HUN.SCNDS.TO.GO! = hundredths of seconds until timeout
  19. '         output: STATUS%   = 0 - delay is complete; 1 - delay is continuing
  20. '/==========================================================================/
  21. '$INCLUDE: 'TICKS.def'
  22.  
  23. STATIC START.TIME!, ENDING.TIME!
  24. IF status% = 0 THEN             'entering for the first time this request
  25.           START.TIME! = FNCTICKS(0)                  ' mark the current time
  26.           ENDING.TIME! = FNCTICKS(HUN.SCNDS!)        ' mark the ending time
  27.           IF ENDING.TIME! < START.TIME! THEN
  28.                      ENDING.TIME! = ENDING.TIME! + TICKS.PER.DAY!
  29.           END IF
  30. END IF
  31.  
  32. CURRENT.TIME! = FNCTICKS(0)
  33. IF CURRENT.TIME! < START.TIME! THEN
  34.           CURRENT.TIME! = CURRENT.TIME! + TICKS.PER.DAY!
  35. END IF
  36. TICKS.LEFT! = ENDING.TIME! - CURRENT.TIME!       'calculate ticks left to go
  37. HUN.SCNDS.TO.GO! = (TICKS.LEFT! * 100) / TICKS.PER.SEC!' see Tech.Ref.
  38.  
  39. IF TICKS.LEFT! > 0 THEN
  40.           status% = 1                         ' time has NOT run out
  41. ELSE
  42.           status% = 0                         ' delay is complete
  43. END IF
  44.  
  45. exitsub:
  46. EXIT SUB
  47. END SUB
  48.  
  49. SUB DELAY (HUN.SCNDS!) STATIC
  50. '----------------------------------------------------------------------------
  51. ' Delay Procedure: Performs a "hard" delay.
  52. ' $MODULE: 'DELAY'
  53. ' input:  an integer representing the number of hundredth-seconds to delay
  54. ' delay == input: HUN.SCNDS! = hundredths of seconds
  55. '----------------------------------------------------------------------------
  56. '$INCLUDE: 'TICKS.def'
  57.  
  58. START.TIME! = FNCTICKS(0)                     ' mark the current time
  59. ENDING.TIME! = FNCTICKS(HUN.SCNDS!)           ' mark the ending time
  60. IF ENDING.TIME! < START.TIME! THEN
  61.     ENDING.TIME! = ENDING.TIME! + TICKS.PER.DAY!
  62. END IF
  63.  
  64. DO
  65.     CURRENT.TIME! = FNCTICKS(0)               ' mark the current time
  66.     IF CURRENT.TIME! < START.TIME! THEN
  67.        CURRENT.TIME! = CURRENT.TIME! + TICKS.PER.DAY!
  68.     END IF
  69. LOOP UNTIL CURRENT.TIME! >= ENDING.TIME!
  70.  
  71. EXIT SUB
  72. END SUB
  73.  
  74.