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 / Record user input without input command

Author
Message
Mega Publishers
16
Years of Service
User Offline
Joined: 17th Dec 2007
Location:
Posted: 21st Sep 2011 00:20
How do you record a users input without the input command? I notice the input command haults the loop, until the user enter a string or so then press enter.

What if you wanted to record a users input without haulting the loop but still be aware of what the user inputed? For example the user sees a sphere spinning and must enter the phrase "stop" to stop the sphere from spinning. How can I do this withing stopping the main loop?
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 21st Sep 2011 01:33
The command I think you are after is:

inkey$()

This returns the string value of the key the user is pressing so hitting the a key returns "a" etc. By putting this in your main loop, you can use simply check it each loop.

A few things to watch though. Firstly I've had a little bit of trouble with this command trying to returns strings of keys that it's not applicable for (backspace) so it's best to check the ascii value of what it's returned before you use it. Also remember that it will keep returning the value of the key so you have to handle spacing out the inputs. By that, I mean that it will return the character to your loop every time the loop runs whilst the key is held down so if you implemented a text box without spacing out the inputs, you would instantly fill the box with the same character just by touching the key.

Hope this helps.

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 21st Sep 2011 02:26
unless he is only searching for the last key being pressed... I think looking at Entry$ may be more appropriate. I'm sure there are some code snippets around making good use of reading and clearing, Clear Entry Buffer, the buffer and reading the windows msg pump.

Have to look over Matrix 1 utils to recall if there is anything better there as well.

Your signature has been erased by a mod please reduce it to 600 x 120.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Sep 2011 00:18
Yes there is, but it's not much:


... a few string commands included, but the big one is SET ENTRY BUFFER, which allows you to write back to the entry buffer. I'm actually using the entry buffer as if it were a global string.

Mega Publishers
16
Years of Service
User Offline
Joined: 17th Dec 2007
Location:
Posted: 22nd Sep 2011 22:50
I tried the above code and it gave a error message "Parameter mismatch in expression entry$(1)
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Sep 2011 23:42
That sounds like you have a very old version of DBPro - you should download and install the latest patch, or the latest beta.

And I also advise that you download and install the latest release of my plug-ins too (if you haven't already), as they are needed for that code to compile.

Login to post a reply

Server time is: 2024-11-24 01:49:38
Your offset time is: 2024-11-24 01:49:38