input time delay

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
Seb McClouth

input time delay

Post by Seb McClouth »

Code: Select all

Do
    A$=inkey$
    if A$ <> "" then
      CMD$ = CMD$ + A$
    end if
    locate y, 2: PRINT CMD$
loop until cmd$ = chr$(13) or ...
I need it this loop a time counter. Either you press any key within a certain amount of seconds or if you don't the loop stops after the certain amount of seconds. How can I achieve this?

grtz
Seb
User avatar
The Awakened
Veteran
Posts: 144
Joined: Sun Aug 07, 2005 1:51 am

Post by The Awakened »

Code: Select all


StartTime! = TIMER     'you could make it an integer if precise timing is not needed

Do
    A$=inkey$ 
    if A$ <> "" then 
      CMD$ = CMD$ + A$ 
    end if 
    locate y, 2: PRINT CMD$ 
loop until cmd$ = chr$(13) or TIMER - StartTime! < AmountOfSeconds

:)

I still havn't finished the Kiwi Bird... damn that thing is hard to draw... :D
"Sorry for beating you up with a baseball bat Julian, but I DID think that you were a samsquanch."
Seb McClouth

Post by Seb McClouth »

Well keep it up. You're getting there!!

grtz
Seb
User avatar
Michael Calkins
Veteran
Posts: 76
Joined: Tue Apr 05, 2005 8:40 pm
Location: Floresville, Texas
Contact:

Post by Michael Calkins »

You might put this inside the loop:

IF starttime! > t! THEN
'crossed midnight, timer went to 0
starttime! = starttime! - 86400
END IF

Regards,
Michael
Bring on the Maulotaurs! oops...
I like to slay Disciples of D'Sparil...
User avatar
The Awakened
Veteran
Posts: 144
Joined: Sun Aug 07, 2005 1:51 am

Post by The Awakened »

Yeah, I didn't include the midnight error handler because I knew he got it from another thread. :)
"Sorry for beating you up with a baseball bat Julian, but I DID think that you were a samsquanch."
Post Reply