| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | delay routine |
Here's some delay code I picked up some time back.
I've got lots of code snippets on disk, the trouble is wading through
them to find them.
Area: alt.lang.basic
Msg#: 1734 Date: 04-02-95 22:45
From: Glen Blankenship Read: Yes Replied: No
To: All Mark:
Subj: Re: QB-sleeping less then
> In plain Quick Basic it is possible to pause the program with the SLEEP
> command. But I need to wait for approx. half a second.
> FOR.. NEXT wait loops are useless ofcourse, due to processor speeds..
SUB Delay (NumTicks%)
FOR i% = 1 to NumTicks%
CurrentTick! = TIMER
DO WHILE CurrentTick! = TIMER
LOOP
NEXT
END SUB
This will delay for the number of system timer ticks (18.2 per second)
specified. It's not absolutely precise, since you may enter the loop at
point during a given tick, so the very first tick won't necessarily be
full duration. Still, for "roughly half-a-second" and suchlike pauses, it
should serve.
The real disadvantage to the code above is if your code doesn't otherwise
use floating-point numbers, since using TIMER will yank in the entire
floating-point library. To avoid that, use:
SUB Delay (NumTicks%)
DEF SEG = &H40
FOR i% = 1 to NumTicks%
CurrentTick% = PEEK(&H6C)
DO WHILE CurrentTick% = PEEK(&H6C)
LOOP
NEXT
DEF SEG
END SUB
...instead. It's functionally identical (it simply peeks at the same BIOS
timer-tick count that TIMER uses), but it doesn't use floating-point
numbers.
To produce a (roughly) half-second delay, use:
Delay 9
-!-
Glen Blankenship
obother{at}netcom.com
--
Pat - La Grande,OR.
ppridgen at greencis dot net
... Life would be much simpler, if I only had the source code.
--- MultiMail/Linux v0.43
* Origin: Try Our Web Based QWK: DOCSPLACE.ORG (1:123/140)SEEN-BY: 633/267 270 @PATH: 123/140 500 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™.