Qbasicnews.com
May 31, 2020, 06:48:15 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Is there a way to set a delay time til next line?  (Read 2167 times)
Placeborick
Member
*
Posts: 35



« on: March 07, 2003, 10:53:51 AM »

I want to make a delay of approx 1.5 seconds between a few lines of code, im sure iv done this before so i know theres a way, but for the love of god i cant remember how. :roll:
Logged

-p
Scrapyard
Forum Regular
**
Posts: 133



WWW
« Reply #1 on: March 07, 2003, 11:19:43 AM »

Use the TIMER lik this:

Code:

Time! = TIMER
DO: LOOP UNTIL TIMER > (Time! + 1.5)


That's all you gotta do  :wink:
Logged

crapyard / Smiley Cheerful Software


"All your base are belong to us"
Zap
Been there, done that
*****
Posts: 1124


« Reply #2 on: March 07, 2003, 12:34:43 PM »

Its also a good idea to put it in a subroutine, makes the code clearer:

Code:


SUB Delay(seconds!)
   Time! = TIMER
   DO: LOOP UNTIL TIMER > (Time! + seconds!)
END SUB




And then just use

Code:
Delay 1.5


if you want to delay for 1.5 secs.
Logged

url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
NovaProgramming
Been there, done that
*****
Posts: 1025



« Reply #3 on: March 07, 2003, 03:00:16 PM »

Good idea, Zap!

DON'T USE THIS : however, as I found out    :lol:

time$ = "00:00"
do:loop until time$ = "00:02"

ARGH it resets the system clock!!??!?!!!!  lol so don't use that, I would use ZAP's idea if I were you.  Good thinking, Zap!
Logged

ovaProgramming.

One night I had a dream where I was breaking balls.  The next morning, BALLSBREAKER was born.

Quote from: "Haye, Phillip J."
 Excellent.  Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Hexadecimal Disaster
Been there, done that
*****
Posts: 1123



« Reply #4 on: March 07, 2003, 10:06:00 PM »

If you people will start using the TIMER for that kind of task, take into consideration the fact that the TIMER will reset after midnight, so if you start using the delay at, let's say 23:59:59, and the delay is set to one or two seconds, the condition LOOP UNTIL TIMER > (Time! + seconds!) will never be fulfilled.

An old sub of mine...

Code:
SUB Aguanta (num!)

Now! = TIMER
o! = TIMER + num!

DO WHILE TIMER < o!
IF Now! > TIMER THEN o! = o! - 86400
LOOP

END SUB


While basically the same, if the aforementioned situation occurs the "start" time will be substracted by 86400. Why that number? 24 hours in a day, 1440 minutes in a day... 86400 seconds in a day.

*sigh*
Logged

img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Mech1031
Na_th_an
*****
Posts: 1536



WWW
« Reply #5 on: March 07, 2003, 11:45:47 PM »

how would you display a timer counting down on the screen? :Huh:
Logged

the mind is a beautiful thing, use it and make the world a more beautiful place.
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #6 on: March 08, 2003, 12:19:14 AM »

each second?

There are many ways. For example using SLEEP 1, although that would not give exact seconds as the rest of the code takes time:

Code:
' crappy, easy sollution
CLS
PRINT "10 seconts to lift off"
locate 2,1:PRINT " 10"
FOR i%=9 TO 0 STEP -1
   SLEEP 1
   LOCATE 2,1:PRINT i%
NEXT i%
PRINT "LIFT OFF!!"


Using timer should give a more accurate sollution .Without taking in account HD's sollution to midnight issue, the code is as follows:

Code:
' Better sollution
CLS
PRINT "10 seconds to lift off"
LOCATE 2,1:PRINT " 10"
FOR i%=9 TO 0 STEP -1
   t!= TIMER
   WHILE TIMER<t!+1:WEND
   LOCATE 2,1:PRINT i%
NEXT i%
PRINT "LIFT OFF!!"


I'm sure that someone can come with another, weirdest sollution Smiley
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!