Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / making a fact practicer with a timer

Author
Message
crazy coyote
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location:
Posted: 2nd Feb 2004 05:55 Edited at: 2nd Feb 2004 08:00
Hi,

I've been working on my first "major" program, which is a program that simply dishes out math facts. That worked well enough, but now I want a timer. I know, to some degree, how to create a timer on its own, but the only command that I know that can recieve text input from the computer is INPUT, and that command apparently stops the loop until the data has been entered. So every time a new fact problem appears, the clock is stalled until the data has been entered, which is not what I want at all.

So how do I create a timer that will keep on ticking, even if the program is waiting for the user to enter data?


Thanks,
Dan

Here's the entire game code, if it's needed. (this is the code in it's messed up form, with a timer that doesn't work.)


EDIT: sorry, I forgot to mention that I am doing this in DBpro.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Feb 2004 15:01
You need to create a loop that detects keyboard input, and appends each keypress to a string. Within your loop, you can continue to do whatever you like, such as update the screen with a clock time etc...

INKEY$ is your friend

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 3rd Feb 2004 23:29
OR (and easier) save the value of the system timer at the start

TempTime=timer()

then when you want a timecheck then subtract that from the current timer...eg

TheTimeInMillisecs=(timer()-TempTime)

then

TimeInSeconds#=TheTimeInMillisecs/1000

or drop the hash to get the time in whole seconds, the function "timer()" returns the system time since the computer started, it will keep on counting whatever the program is doing (waiting for input or just running an empty loop), and would be ideal for what you want.

Mentor.

System spec : Pentium 3.0Ghz, 512MB DDR, 2x160Gb HD (using icewave hd coolers ), DVD RW/CD RW (all modes), multimedia front panel, 6 way surround sound, ATI radeon 9800Pro 128mb.
Ralen
21
Years of Service
User Offline
Joined: 22nd Jul 2003
Location:
Posted: 4th Feb 2004 03:18
Mentor, read the entire post next time...

better than inkey$ is the entry$() function.
See inkey$ has a problem with not catching everything typed on the keyboard, entry$() is basically a inkey$ + buffer in one. The only real draw back is you have to use some extra code to get it to detect when you use keys like backspace and enter.

Ralen

Login to post a reply

Server time is: 2024-11-26 03:27:55
Your offset time is: 2024-11-26 03:27:55