TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: All
from: Greg Easthom
date: 2004-03-15 16:23:08
subject: Code FAQ [5 /15

'>>> Page  5  of Code FAQ begins here.


   You could use SLEEP 2.  This, however, has problems: integer
   numbers only, user can hit _ANY_ key to jump out of it, and
   that key will be held in the buffer waiting to bite the next
   INPUT command unless dumped with DO: LOOP UNTIL INKEY$ = ""

   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  5  of Code FAQ ends here. Continued in next message.

 * Brought to you by Greg's Little QBasic Auto-Poster *

--- Maximus 3.01
* Origin: The BandMaster, Vancouver, B.C., Canada (1:153/7715)
SEEN-BY: 633/267 270
@PATH: 153/7715 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.