Posts: 7
Threads: 3
Joined: Oct 2003
A simple question:
The SLEEP command stops the application until the user pushes any key, but how do I do to force the user to hit a certain key (eg space) to let him continue running the program?
Thanks in advance!
size=8]Select From Neoneh Where QBKnowledge = 1337
IF RS.EOF THEN Response.Write "He's a noob.."
ELSE
Response.Write "No, that's impossible!"
END IF[/size]
Posts: 773
Threads: 71
Joined: Mar 2002
SLEEP 6000
Hehehe!
I don't know...
WHILE Inkey$=""
WEND
:normal:
Posts: 1,080
Threads: 87
Joined: Feb 2002
Code:
DO: LOOP UNTIL INKEY$=" "
/post]
Posts: 7
Threads: 3
Joined: Oct 2003
Quote:Code:
DO: LOOP UNTIL INKEY$=" "
Kanoners! tack
size=8]Select From Neoneh Where QBKnowledge = 1337
IF RS.EOF THEN Response.Write "He's a noob.."
ELSE
Response.Write "No, that's impossible!"
END IF[/size]
Posts: 175
Threads: 36
Joined: Oct 2003
Code:
Do
khb$ = inkey$
'your code goes here
loop untill khb$ = "g"
You can replace g with any other letter, number or character.
Or if you want to use a key like escape then you use the ascii code chr$(27). where 27 is the code for ESC.
You can view a list of all the ascii character codes, using the qbasic help. In the contents, there is a link to them.
Code:
Do
KHB$ = inkey$
'your code here
loop until inkey$ = chr$(27)
Also you could use
Code:
DO
khb$ = inkey$
'your code here
if inkey$ = "g" or inkey$ = chr$(27) then goto 100
loop
100
'more code
note: the "or inkey$ = chr$(27)", is not necessary.
eminiscing about trapezoids in conjunction with stratospherical parabolas:
No questions asked.
www.stickskate.com
Posts: 1,845
Threads: 44
Joined: Aug 2002
try to avoid GOTO. Better use EXIT DO in this example (the last one).
Posts: 773
Threads: 71
Joined: Mar 2002
You should use a library. Unless you enjoy POUNDING on your keyboard.
Posts: 26
Threads: 7
Joined: Aug 2003
In this case I personally (although my opinion is really inferior compared to some other people here) would use something like;
99
INPUT " "; yourvariablehere
IF yourvariablehere$ = "key you want them to hit here" THEN
GOTO 1 '(Place a one in front of you continued program)
END IF
BEEP
PRINT "Invalid Answer"
SLEEP 5
GOTO 99
And that would tell the person that their answer was incorrect. By using this system you can also make other keys register certain commands; such as to just exit the program altogether, or stop it for modifications. Its all up to you. However, when using the goto and input commands together, it is importaint not to get caught in an infinate loop.
So, yeah. There are some cases when the GOTO command is not evil. You just have to know how to harness its evil power.
.
S VERDAD?!
Posts: 13
Threads: 1
Joined: Oct 2003
When told to "Goto Hell" a programmer believes the instruction is worse than the destination
Posts: 1,166
Threads: 62
Joined: Apr 2003
Quote:When told to "Goto Hell" a programmer believes the instruction is worse than the destination
Good joke, I'm assuming you're new to this forum, but not to programming?
am an asshole. Get used to it.