feelin' sleepy

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Hrothgar
Coder
Posts: 25
Joined: Tue Nov 22, 2005 8:32 pm
Location: Perth, Oz

feelin' sleepy

Post by Hrothgar » Mon Feb 20, 2006 7:19 am

Is there a way to get my program to wait for a certain amount of time that doesn't have the problem SLEEP does whereby if you push any key it skips the wait?

I thought about using TIMER but I was wandering if there were any other alternatives?

Edit: forget it I didn't realise there were any other parameters for "SLEEP" :oops:
Image
Towels may be harmful if swallowed in large quantities.

User avatar
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations » Tue Feb 21, 2006 1:04 pm

I only recommend SLEEP if you want the user to be able to get out of it by pressing a key. If not, use this DELAY sub.

Code: Select all

SUB Delay (sec!)
LET stoptime! = TIMER + sec!     'sec! is the amount of delay in seconds
WHILE TIMER <> stoptime!
IF stoptime! > 86400 THEN stoptime! = stoptime! - 86400   'Midnight fix.
WEND
END SUB
I added the Midnight Fix because moneo reminded me about it in an earlier topic. :P

Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re » Tue Feb 21, 2006 1:33 pm

Patz QuickBASIC Creations wrote:I only recommend SLEEP if you want the user to be able to get out of it by pressing a key. If not, use this DELAY sub.

Code: Select all

SUB Delay (sec!)
LET stoptime! = TIMER + sec!     'sec! is the amount of delay in seconds
WHILE TIMER <> stoptime!
IF stoptime! > 86400 THEN stoptime! = stoptime! - 86400   'Midnight fix.
WEND
END SUB
I added the Midnight Fix because moneo reminded me about it in an earlier topic. :P
He's using freebasic.. sleep delayms, 1
I have left this dump.

Post Reply