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 / ESC key exit only

Author
Message
MAK777
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 15th Feb 2009 06:11
How do I exit my program only when I press the Escape key without having the program looping?
Thanks.
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 15th Feb 2009 11:54
if your program doesn't loop, then it'll just end? without u having to press anything.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
castek
17
Years of Service
User Offline
Joined: 15th Aug 2007
Location: Right behind you!
Posted: 15th Feb 2009 22:10
if escapekey()=1 then end

Is that what you meant?

I dont know if that works though.

"The Beginning is the end."
Windows Vista Ultimate SP1
INTEL PENTIUM DUAL E2200 2.2 GHz 2 Gb RAM GeForce 9600 512 mb
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 15th Feb 2009 22:38
It think you mean that your program does not have a loop, but you don't want it to quit when it gets to the end? Try putting WAIT KEY at the very end.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 16th Feb 2009 04:32
Either you dont use any loops at all and put in a wait key statement... Which is essentially a loop in itself that continously loops checking for a keypress - you could make your own wait key command that waits for a specific key to continue, like this:



Replacing the key variable with the scancode of the key you want to detect. You could expand it to accept multiple keys with a simple addition statement:



Etc... or if you wanted it to be more efficient you could store all of the keys you want to check for inside an array and check for these keys in a for...loop inside the repeat loop like this:



OR just use wait key, eg;



The benefit with creating your own command to wait for a key is that you CAN put it inside a loop and have other things continue happening while it waits for the escapekey, instead of halting the program to wait for a key like the wait key does.

MAK777
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 22nd Feb 2009 05:21
Hi,
I'll try what you said RUCCUS.
I don't want my program to loop. It is supposed to be a game out of text where you press number keys to select choices and I don't want the text to loop and keep being displayed.
Thanks.

Login to post a reply

Server time is: 2024-11-25 10:39:03
Your offset time is: 2024-11-25 10:39:03