Here is a screen capture of what is happening.
Here is the code, no media required. The code should execute as is.
`Dim Global variables
Dim mtextbox_dictionarylist$(1000)
Global mtextbox_dictionarycount as integer
`Throw something into the global variables
mtextbox_dictionarycount = 1
mtextbox_dictionarylist$(1) = "ABBA"
`Run the code and paste the result to the screen.
Do
A$ = MTtextBox_DictionaryFind("ABE")
Print A$
sync
loop
`Finds the suggested dictionary list word using provided string. returns suggested word.
`requirements are that provided string be the starting of suggested string.
Function MTtextBox_DictionaryFind(oString$)
`Run through each of the words in the dictionary
For i = 1 to mtextbox_dictionarycount
dString$ = mtextbox_dictionarylist$(i)
kString$ = mtextbox_dictionarylist$(i + 1)
`If given string is higer value than current entry suggest nothing. The list is sorted so no need to continue.
If oString$ > dString$ Then ExitFunction ""
`If given string matches an entry then suggest nothing.
If oString$ = dString$ Then ExitFunction ""
`If the next entry is lower value than given string then compare current entry if a suitable suggestion exists it will be here.
If oString$ > kString$
If MTextBox_DictionaryInstr(oString$, dString$) = 1 Then ExitFunction dString$
EndIf
Next i
`Searched whole dictionary, found nothing then suggest nothing.
EndFunction ""
`This function will compare strings. Returns 1 if oString$ is at beginning of dString$
`This is for search functionality.
Function MTextBox_DictionaryInstr(oString$, dString$)
`If dString is too short then send fail code
If LEN(dString$) < LEN(oString$) Then ExitFunction 0
`Compare each character, fail if there is a mismatch
For i = 1 to LEN(oString$)
If MID$(oString$, i) <> MID$(dString$, i) Then ExitFunction 0
Next i
`Nothing failed so send pass code. oString$ must be the beginning of dString$
EndFunction 1
Why does this crash? I am getting annoyed as it seems returning strings is crashing things.