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 / inkey$ command help

Author
Message
aarrowh
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 19th Feb 2008 04:16
Ok, so I tried making my own text game, and I've gotten to where I need to make multiple choice questions, so I tried using the inkey$ command, the program opens fine, but when I push the button I declared nothing happens, although this is the first time I've used the command I'm guessing I'm doing somthing wrong. Here's my source code.



P.S. Please don't flame me for a crappy game/source. Its my first program.

Ima DBpro noob...haha
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 19th Feb 2008 12:31 Edited at: 20th Feb 2008 05:13
inkey$() is not like input. it doesn't wait for anything (enter key, or otherwise).
it is whatever key is pressed when the command is called (or, if nothing is pressed, inkey$() = "", or null).

since you didn't place inkey$() in a loop, you gave your program 1 cycle to determine what inkey$() will be.
if "1" wasn't pressed before/while the command was called, inkey$() cannot be "1".

so, either put it (the inkey$() request) in a loop and make it loop until a valid option is chosen, or use input (or choose another method altogether).

hope that helps. if not, ask away

edit:
run this:


edit2 removed last input$ typo and replaced with input so as not to confuse anyone who might stumble across this thread.

Virtual Nomad
AMD XP 1800+ (~1.6 Ghz) / 1.5 GB RAM
ATI Radeon 8700LE 128 MB / Windows XP
aarrowh
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 19th Feb 2008 19:14 Edited at: 19th Feb 2008 19:20
Ok, thanks, I'll try that. Um, incase it dosn't work, how exactly do you use the input$ function, because I couldn't find it in the help content.

*edit*
I tried what you posted, and all it did was crash the program. Could it be that I'm running Vista?

[link]mavrickgamedesign.webs.com[/link]
aarrowh
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 20th Feb 2008 04:01
bump.

help?

[link]mavrickgamedesign.webs.com[/link]
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Feb 2008 04:36 Edited at: 20th Feb 2008 04:46
Quote: "how exactly do you use the input$ function"


There's no such thing.

There's Input and Inkey$() - both of which are covered in detail in tutorial 3 - Beginners Guide To Programming - Part III, which can be found here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

As for your program crashing:

input "now you got it: ", WeAreAllNoobs$

should be:

input "now you got it: ";WeAreAllNoobs$

but I'm sure that in itself is in no way the reason your program crashes.

In fact, it's more likely that your program is not crashing at all - it's just ending because you don't have a Wait Key as the last line of the program.

TDK_Man

aarrowh
17
Years of Service
User Offline
Joined: 19th Oct 2007
Location:
Posted: 20th Feb 2008 04:44
Thanks alot TDK!

[link]mavrickgamedesign.webs.com[/link]
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Feb 2008 04:48
No problem.

By the way, I edited my last post while you were typing yours, so in case you didn't see it, I've added a bit of info about your program crashing... or not as the case may be.

TDK_Man

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 20th Feb 2008 05:16 Edited at: 20th Feb 2008 05:17
Quote: "
input "now you got it: ", WeAreAllNoobs$

should be:

input "now you got it: ";WeAreAllNoobs$

"


for clarification purposes, input accepts both semicolons and commas (which are shown in the help file).

and, sorry for that typo showing "input$" instead of "input" toward then end there. i went and edited it so noone else gets mis-informed.

Virtual Nomad
AMD XP 1800+ (~1.6 Ghz) / 1.5 GB RAM
ATI Radeon 8700LE 128 MB / Windows XP

Login to post a reply

Server time is: 2024-11-25 07:46:13
Your offset time is: 2024-11-25 07:46:13