1. inputing from keyboard
- Posted by fred Feb 19, 2009
- 819 views
if you input or get key can you put a full sentence in a data base and check against known words
2. Re: inputing from keyboard
- Posted by DanM Feb 19, 2009
- 802 views
if you input or get key can you put a full sentence in a data base and check against known words
Yes, I don't see why you couldn't use get_key() to do that.
If you do use get_key(), you must put it inside a fairly tight loop, as the function does not wait until you're finished typing to proceed on, so a tight loop would insure that you get all keypresses. And you'd have to save each keypress in an accumulating variable, and constantly test every keypress for <enter>/<return> in order to exit the loop and proceed to your use or test of the accumulated input.
You probably should also put the keypresses onto the screen, so that if a key IS missed, it could be noticed by the user.
The resulting sequence of keypresses, if you saved them to a variable correctly, would certainly be able to be stored in a data base, though if you're checking against known words, I'd think you might want to do that checking before putting it in there, in case you need to advise the user to repeat their input, though your specific intended purpose may validly suggest otherwise.
And you'd want to clear the variable you used to accumulate the keypresses quickly, in case more keypresses are presented.
Dan
3. Re: inputing from keyboard
- Posted by DerekParnell (admin) Feb 19, 2009
- 802 views
if you input or get key can you put a full sentence in a data base and check against known words
It sounds like you are fairly new to computer programming. Welcome. There are many people here who can help you learn to program well and also learn the Euphoria programming language.
Maybe we can begin with a bit more detail about what you are trying to achieve with your program. Your initial question is pretty open to lots of interpretation, so how about you narrow it down a bit more. For example, is this a text game you are writing? Or maybe something else? How do you see users of the program operating it?
But as your question stands, the simple answer is 'yes'.
The get_key routine collects whatever keyboard button is pressed, one at a time. To get a whole sentence (line?) you have to use the get_key() routine repeatedly until your program decides that the whole sentence (line?) has been entered by the user. If you want to, you can add that line to a database before or after you check it for known words (spell checking?).
Your program would need to break up the sentence into a set of words and compare them to a 'dictionary'. What you do with incorrect words will also be under your control, so you need to decide what to do in those circumstances.
Let us know a bit more about your aims and we can provide a lot more detailed advice etc ...
4. Re: inputing from keyboard
- Posted by fred Feb 20, 2009
- 792 views
Thank u for you’re reply. The database I will use will just have the key words to found. The poison of the word will make a code such as 3978 meaning what time is bus. With This one you could just put time bus. If the program needs more info or doesn’t understand it will say so and go back for more input. I’m use to basic where you put the info into key$ then word1$=word1$+key$ .I don’t remember using a for next loop for this. But I did for the database. This is quite some time ago so it’s hard to remember it. I have wanted to put this in euphoria for a while but it seems harder than basic .I seam to remember that I could put a whole sentence in one go in to a data base then it would against anther data base. Anyway thank for all help so far
5. Re: inputing from keyboard
- Posted by mattlewis (admin) Feb 20, 2009
- 824 views
Thank u for you’re reply. The database I will use will just have the key words to found. The poison of the word will make a code such as 3978 meaning what time is bus. With This one you could just put time bus. If the program needs more info or doesn’t understand it will say so and go back for more input. I’m use to basic where you put the info into key$ then word1$=word1$+key$ .I don’t remember using a for next loop for this. But I did for the database. This is quite some time ago so it’s hard to remember it. I have wanted to put this in euphoria for a while but it seems harder than basic .I seam to remember that I could put a whole sentence in one go in to a data base then it would against anther data base. Anyway thank for all help so far
While the previous responses were correct as far as what you can do for using get_key(), etc, they're not the easiest way to emulate that behavior. Take a look at the prompt_*() family of functions in get.e for an easier way to get a sentence from the user.
Matt