'>>> Page 4 of CODE0498.FAQ begins here.
TIMER can be used - it ticks off 1/18.2 of a second:
delay = 2
finish = TIMER + delay
DO
LOOP UNTIL TIMER => finish
This works, but has a fatal midnight flaw: the timer is reset
to 0 at midnight and it is therefore possible that "finish"
will never be reached. It's easy to test for midnight (there
are 86,400 seconds in a day). I leave that as an exercise for
the reader!
However, it is easy not to depend on TIMER to do the counting -
count it yourself. Something like:
delay = whatever
t! = INT(TIMER)
DO
IF t! INT(TIMER) THEN
t! = INT(TIMER)
count = count + 1
PRINT count
END IF
LOOP UNTIL count = delay
This routine doesn't care what the reading of TIMER is, only
that it has changed. A roll-over at midnight is just as valid
a change as an increase of one second. If you want 1/10's of a
second, you'll need to alter accordingly. Since TIMER ticks at
18.2 times a second, the smallest interval will be 0.0549450549
sec.
[end quote]
If you're looking for something else, Chad Beck suggests the
following:
[quote]
Here's a delay routine[...]: it's small, it doesn't use
floating point values, it has an 18th of a second accuracy,
and it accounts perfectly for midnight. Num18ths is the number
of 18ths of a second that you want to delay for. [In other
words, Num18ths is the number of seconds you want in the delay,
times 18 -- or, more accurately, 18.2.]
DEFINT A-Z
DEF SEG = 0
FOR Delay = 1 to Num18ths
Timr = PEEK(&H46C) 'Read BIOS timer tick count
DO
LOOP WHILE Timr = PEEK(&H46C)
NEXT
[end quote]
4) WHAT ARE INTERRUPTS, AND HOW DO I USE THEM?
INTERRUPTs are built-in general purpose functions that can be
accessed by a programmer of most every language. They can
really give you some nice results. Essentially, they add many
useful functions to the Basic language. One note here: they
MUST be done in QuickBasic, as QBasic doesn't have the CALL
INTERRUPT option. Also, you *must* load QB with the /L switch.
The first step is to include the QuickBasic include file at the
beginning of your program:
'$INCLUDE: 'qb.bi'
This includes the TYPE definitions required to use the
INTERRUPTs. The next statement to enter, when you want to use
an INTERRUPT, is:
DIM InReg AS RegType, OutReg AS RegType
You can call InReg and OutReg anything you want, but it's a
good idea to make sure you know which is "in" and which is
"out." You can now assign values to the AX, BX, CX, DX, BP,
SI, DI, and Flags "registers" now defined in InReg and
'>>> Page 4 of CODE0498.FAQ ends here. Continued on next page.
___
* SLMR 2.0 * C:\DOS C:\DOS\RUN RUN\DOS\RUN
--- Maximus/2 3.01
---------------
* Origin: The I.O. Board - 4GB -XX- V34+ (1:2255/10)
|