BBS: Inland Empire Archive
Date: 10-26-93 (09:02)             Number: 353
From: DOUGLAS LUSHER               Refer#: NONE
  To: JASON SHARPEE                 Recvd: NO  
Subj: QB DELAY                       Conf: (2) Quik_Bas
JS>   I need a way to pause my program for a 'n' number of milliseconds.  I
JS>have found a routine that will do an 18th of a second, but this is too
JS>long of a delay yet.  Any help would be appreciated!

There are ways to do this which involve asm code and reprogramming
the timer chip in your pc. Not something for the faint of heart.
Here's an alternative that may work for you, and it's simple
BASIC code - although you may need to tweak it a bit. The
fundamental idea is to have your program time the pc that it is
running on when it (your program) starts up. The code I'm
supplying below does this by seeing how many times your PC can
increment a long integer variable during a single clock tick.
This is what the function TimeFactor& does. Since the length
of a clock tick is known, it is a simple calculation to find
the number of times that the PC can increment a long integer
variable in a single millisecond. And this can be used to produce
delays of the desired length. SUB MDelay, code supplied below,
will do this if passed the number of milliseconds to delay,
and the time factor returned by the TimeFactor& function.
good luck.

  Factor& = 0
  DEF SEG = 0
  Start% = PEEK(&H46C)
  DO: LOOP WHILE PEEK(&H46C) = Start%
  Start% = PEEK(&H46C)
  DO: Factor& = Factor& + 1: LOOP WHILE PEEK(&H46C) = Start%
  TimeFactor& = Factor&

SUB MDelay (MSecs%, Factor&)
  FOR X% = 1 TO MSecs%
    LoopTime& = Factor& \ 40
      LoopTime& = LoopTime& - 1
    LOOP WHILE LoopTime&

  SLMR 2.1a  I love it when a plan comes together.
--- QM v1.26/a
 * Origin: TC-AMS MLTBBS 2.2 [64] - Minnetonka MN - (612)-938-4799 (1:282/7)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET