02-25-2026, 10:16 PM
For example:
Code: (Select All)
Screen _NewImage(1024, 720, 32)
$Color:32
ReDim dict(0) As String
t1 = Timer(0.001)
LoadWordList "Scrabble WordList 2006.txt", dict()
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) '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(250000) As String 'let's make a nice large array to told the words.
' I doubt any word list is going to have more than 250,000 words in it!
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

