Click here to LOGIN
Information
Tutorials & Articles
Programs
Feedback
 


Forum
Add a Post
Username:   (You must log on to use your member username)Hint: Use [code] and [/code] around text to highlight it as QB code.


Subject:
Message:
Forums -> Q & A -> A Qbasic Timer
JonCraig
A Qbasic Timer
Posted Dec 08 2009
I am unsure of how to create a timer in qbasic that will display a message say, every 2 minutes. 
seaBiscuit$
Start with a delay timer
Posted Dec 08 2009
Then put the delay in a loop, so it's a loop full of delays.

Flow should look like this:

do
    wait for two minutes
    display message
loop



which will loop and every two minutes will display the message.

Look into TIMER to make the delay.  It returns the number of seconds since midnight.  You then want to wait until the value of TIMER is 120 seconds greater than what it started at.  You can use another loop for that.
JonCraig
I understand the logic behind this.
Posted Dec 08 2009
I do understand the logic behind this, and this helps.  I am just unfamiliar with the language..


Clippy
TIMER
Posted Dec 09 2009
Use the TIMER in QB as a Single value.

start! = TIMER
DO WHILE TIMER < start! + 120 ' 2 minutes = 120 seconds
LOOP
PRINT message$
debiani386
another string that has always worked good for me
Posted Mar 02 2010
This string was posted by someone else on this forum (I cant remember who right off the top of my head, it was 3 years ago).


timeout = 5
t = timer
do while t + timeout >= timer
   if t > timer then t = t-86400
loop

Clippy
ON TIMER
Posted Mar 03 2010
ON TIMER(120) GOSUB message
TIMER ON

message:
PRINT "This will be printed every two minutes!"
RETURN

TIMER events will happen independantly from the program code. It may interrupt SLEEP calls.

The QBasic Station, (C) Copyright 1997-2010