home *** CD-ROM | disk | FTP | other *** search
-
- TIMING AND TIME-OUT SubPrograms for QUICKBASIC
- ==============================================
-
- This document discusses:
-
- -Programming with the timing routines DELAY & BGDELAY.
-
- -Using TIMERS.BAS and INT86.OBJ in a user run-time library.
-
- -BIOS interrupt 1Ah.
-
-
- [This document and the software it describes were prepared by
- Ken Karp. You may reach me at the QuickBASIC conference on the
- MicroSellar BBS at (201) 239-1346 (NJ), or write to me at
-
- 444 Sagamore Ave.
- Teaneck, NJ 07666
-
- You are free to do ANYTHING with these files as long as you do not
- (1) distribute any changes to them under my name, or (2) attribute
- such changes to me in any way.]
-
-
-
-
-
- PROGRAMMING WITH THE TIMING ROUTINES DELAY & BGDELAY
- ====================================================
-
- (1) DELAY - this SubProgram is very simple in concept. You merely
- CALL DELAY (N!). DELAY will loop until N! hundreths of
- seconds have passed. NB: N! MUST be Single Precision (*!*)
-
- (2) BGDELAY - performs `background' timing while you perform some
- other task of your own in `foreground'. For instance:
-
- PRINT "You have 10 seconds to answer."
-
- STATUS%=0
- H.SCNDS!=1000
- DO
- GOSUB <do your own thing>
- CALL BGDELAY (H.SCNDS!,TO.GO!.STATUS%)
- Z$=INKEY$
- LOOP UNTIL Z$<>"" OR STATUS%=0
-
- IF STATUS%=0 THEN
- PRINT "Your time has expired!"
- ELSE
- PRINT "You pressed ";z$
- END IF
-
- will print the "10 seconds..." warning, and then loop until
- EITHER a key is pressed OR 10 seconds (1000 hundredth
- seconds) passes. Notice that this gives you an opportunity
- to do things on your own while you are waiting for one of
- those two things to occur (thus the phrase `background'
- timing). Some of the things that you may want to do
- include print the time remaining (like the example set
- forth in TIMETEST.EXE), print the time of day, monitor a
- communications port, blank out the screen after 5 minutes
- of no typing, et.al.
-
- The parameters for BGDELAY are:
-
- H.SCNDS! - hundredths of seconds you want to wait the
- timeout occurs.
- TO.GO! - hundredths of seconds left to go (if you print
- this out in the loop you will be `counting down' --
- see TIMETEST.BAS).
- STATUS% - must be set to 0 before the first call ONLY (before
- entering the loop!); after that, TIMERS sets it
- for you to test as follows: 1 indicates that
- there is more time left, and 0 indicates that the
- timeout has finally occurred.
-
-
-
- USING TIMERS.BAS IN A USER RUN-TIME LIBRARY
- ===========================================
-
- The recommended, but not required, procedure for using TIMERS.BAS
- is to place the object file (TIMERS.OBJ) AND MicroSoft's INT86.OBJ
- into a MiscroSoft user run-time library. The file TIMERS.EXE is
- a user run-time library that contains these two object files.
-
- The only restriction in usage is: IF YOU DO NOT USE TIMERS in a
- run-time library then you must not initiate a timing sequence in
- one program and CHAIN to another program to check on the timeout.
- This is due to the fact that TIMERS.OBJ maintains STATIC variables
- that must not be disrupted during the course of a single timeout
- cycle. If you do not use CHAINing between calls, you will have no
- problem.
-
- If you are using the QuickBASIC v3.0 integrated environment you
- MUST place INT86.OBJ into a run time library. TIMERS.OBJ may be
- placed into the same run-time library, or TIMERS.BAS may be
- $INCLUDEd into your source code.
-
- If you are using static library(s) (ie, .LIB files), you may add
- TIMERS.OBJ and INT86.OBJ to them, or you may add them as object
- modules at LINK time (eg, LINK MYPROG+TIMERS+INT86+...+,...).
-
-
- NB: INT86.OBJ (and INT86.ASM) are distributed with QuickBASIC
- v3.0. INT86.OBJ may be called from a QuickBASIC v3.0 program to
- perform any 8086 interrupt. TIMERS uses it to perform BIOS
- interrupt 1Ah (see below).
-
-
-
- BIOS INTERRUPT 1Ah
- ==================
-
- BIOS interrupt 1Ah performs time of day functions. TIMERS calls
- interrupt 1Ah with an argument of 0 in AH to obtain the clock
- ticks since midnight. Although BIOS's change from one PC
- "compatible" computer to another, this particular call is very
- fundamental, and I would expect most (if not all) clones to
- service it. If you find that TIMERS does not work as expected on
- your machine, and you wish to get it to work, you may contact me
- as outlined at the beginning of this document and I will try to
- help you.