autocompletition?

Blitz3D Forums/Blitz3D Beginners Area/autocompletition?

pimpom(Posted 2007) [#1]
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.


Yo! Wazzup?(Posted 2007) [#2]
Maybe this?
partofword$=Input("")
Global dirword$="canada"
find$=partofword$
location=Instr(dirword$,find$)
If location=1 Then
	Print dirword$
Else
EndIf



Buggy(Posted 2007) [#3]
That won't work... Input stops the program.


pimpom(Posted 2007) [#4]
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.


Yahfree(Posted 2007) [#5]
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


b32(Posted 2007) [#6]
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


pimpom(Posted 2007) [#7]
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.