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 / how do i tell DarkBASIC to end program with pressing a key?

Author
Message
Kestrel18
17
Years of Service
User Offline
Joined: 9th Dec 2006
Location:
Posted: 10th Dec 2006 00:09
how do i tell DarkBASIC to end program with pressing a key?
Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 10th Dec 2006 02:51 Edited at: 10th Dec 2006 02:54
use the "end" command
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 10th Dec 2006 03:19
Again, here is code exampling what Jerok showed you, doing what you need.



-Mansoor Siddiquie

Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 10th Dec 2006 03:35 Edited at: 10th Dec 2006 03:36
If you want it to end when pressing a specific key, use keystate. The code to make it end when you hit backpace would be this:

if keystate(14)=1
end
endif

If you need to find what number a key is then simply run the program:

do
print scancode()
loop

and while in the program hold down the key you want to use, and it will give you a number. You just substitute that number into the original bit of code I gave you where 14 is. I just used 14 in my example since I happen to know which key it is.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Dec 2006 03:42
If you aren't that advanced with DB yet and you are writing small programs that don't involve a main loop, then you might only need:

Print "Press Any Key To Exit"
Wait Key
End

... at the end of your program.

Otherwise the answers above are what you need.

TDK_Man

Kestrel18
17
Years of Service
User Offline
Joined: 9th Dec 2006
Location:
Posted: 12th Dec 2006 02:02
Actually to one Deamon used was what I was looking for because, I don't really understand how I was supposed to make say my Esc key the key I press to exit the program and nothing else, because I did use the WAIT KEY but the problem with that was I wanted to use MOVE CAMERA WITH ARROWKEYS and well the program would end if I tried to move the camera.

Login to post a reply

Server time is: 2024-11-26 05:45:54
Your offset time is: 2024-11-26 05:45:54