02-25-2026, 10:25 PM
And with the dictionary bplus used for his:
less than a second or so from start to finish for me, and this is without trying to optimize anything or make it speedy. Load and parse 270k words into an array. Search that array from top to bottom 100 times... and the whole process is less than a second. For most applications with words, it's going to be more than fast enough for whatever type of lookup you might be doing.
Code: (Select All)
Screen _NewImage(1024, 720, 32)
$Color:32
ReDim dict(0) As String
t1 = Timer(0.001)
LoadWordList "Collins.txt", dict(), 300000
t2 = Timer(0.001)
Print Using "#.##### seconds to load ###,### words."; t2 - t1, UBound(dict)
For i = 1 To 10
Print dict(i),
Next
Print
For i = UBound(dict) - 10 To UBound(dict)
Print dict(i),
Next
Print
'and just to showcase how quick arrays are, let's do a random search of the array from start to bottom
For i = 1 To 100 'let's look for 100 random words
word$ = Chr$(65 + Rnd * 26) + Chr$(65 + Rnd * 26) + Chr$(65 + Rnd * 26)
match = _FALSE
For j = 1 To UBound(dict)
Color Yellow
If word$ = dict(j) Then Print "MATCH:"; word$,: match = _TRUE
Color White
Next
If _Negate (match) Then Print "No match:"; word$,
Next
'note that this is doing nothing to binary search, nor is it exiting after finding a match, nor doing anything else to speed up the process
'this is simply testing the entire word array one by one looking for a match for our words.
'and it takes... no noticable time at all.
Sub LoadWordList (file$, WordList() As String, Limit As Long) 'this sub loads a list of words for use later
$Checking:Off
Dim As String temp, t1
Dim As Long count, p, p1
ReDim WordList(Limit) As String 'let's make a nice large array to told the words. Set the limit you want for yourself
If _FileExists(file$) Then 'then we have a found word list. Let's load and parse it
temp = _ReadFile$(file$)
p = 1
Do
p1 = InStr(p, temp, Chr$(10)) 'look for a chr$(10) end of line marker
If p1 = 0 Then p1 = InStr(p, temp, Chr$(13)) 'if no chr$(10) then look for a chr$(13) for odd files with it as the CRLF
If p1 Then 'then we have a delimiter
t1 = _Trim$(Mid$(temp, p, p1 - p))
If Right$(t1, 1) = Chr$(13) Then t1 = Left$(t1, Len(t1) - 1) 'if CRLF then strip off chr$(13)
If t1 <> "" Then 'don't add blank lines to the list
count = count + 1
WordList(count) = t1
End If
p = p1 + 1
End If
Loop Until p1 = 0
If p < Len(temp) Then 'if there's no CRLF for the end of file, we want to last word here
t1 = Mid$(temp$, p)
If t1 <> "" Then 'again, don't add if it's a blank line
count = count + 1
WordList(count) = Mid$(temp, p)
End If
End If
End If
ReDim _Preserve WordList(count) As String
$Checking:On
End Sub
less than a second or so from start to finish for me, and this is without trying to optimize anything or make it speedy. Load and parse 270k words into an array. Search that array from top to bottom 100 times... and the whole process is less than a second. For most applications with words, it's going to be more than fast enough for whatever type of lookup you might be doing.

