autocompletition?
Blitz3D Forums/Blitz3D Beginners Area/autocompletition?
| ||
Hi, I am planning on starting a simple "notepad" like text editor, and was thinking on how to implement autocompletition. So for example, if user type ca, a small popup would show: can canada car carrot etc.. I guess a dictionary would be needed, but how to make comparisson to possibilities? Anyone has experience in this sort of things? Thanks in advance for any ideas. |
| ||
Maybe this?partofword$=Input("") Global dirword$="canada" find$=partofword$ location=Instr(dirword$,find$) If location=1 Then Print dirword$ Else EndIf |
| ||
That won't work... Input stops the program. |
| ||
Hey, thanks for your thoughts, I will make a temporal variable to count chars and get rid of spaces, before putting them to screen, so hopefully something like Yo! Wazzup? posted will do the trick. Thanks. |
| ||
Mabye this helps for a text field, you cn yank the meat out of the code and adapt for your own needs: http://blitzbasic.com/codearcs/codearcs.php?code=2006 |
| ||
I think you need a list of words that is sorted alphabetically. You can compare strings as if they were integers: If "Ambient" < "Zelda" then print "A is before Z" You could store all the words in a Type and search through them while the user is typing. I would add all typed characters to a temp. string, that is reset whenever the user presses space. With Lower$/Upper$ you can make a string either lowercase or uppercase: x$ = Upper$(x$) This makes it easier to compare the input to the wordlist. Then, I would read all the words into a type, and use First and After to search through the list. If inputword$ > currentitem\word$ then currentitem = After currentitem I don't know if you have a wordlist? Diablos posted one here a while ago: http://socoder.net/index.php?topic=439 |
| ||
Hey, thanks to all!! Indeed great ideas. b32 thanks, didnīt knew strings could be compared like that. I do have a list of words, but thanks a lot! Yahfree, I will look more closely and look at your code, seems wome parts will be quite handy. I will be out of town for a while, hopefully back in a week with a working project. Thanks again, if stuck will come back again. Cheers. |