02-26-2026, 02:51 PM
(02-25-2026, 08:58 PM)bplus Wrote: Inspired by mdijkens comment here: https://qb64phoenix.com/forum/showthread...9#pid40209That's indeed what I had in mind. (dont forget FStr$ = Chr$(13) + Chr$(10) + ReadFile$("Words.txt") to also find first word in file)
This is really easy way to confirm if a word is in a file list of words say from Collins Dictionary:
Code: (Select All)_Title "Test IsWord function" 'bplus 2026-02-25
Dim Shared FStr$
FStr$ = _ReadFile$("Words.txt") ' once and for all time
While 1
Input "Enter a word to see if in Collins Dictionary"; w$
If IsWord%(w$) Then Print w$; ", is a word." Else Print w$; ", is Not a word"
Wend
Function IsWord% (test$)
testeol$ = Chr$(13) + Chr$(10) + UCase$(test$) + Chr$(13) + Chr$(10)
If InStr(FStr$, testeol$) Then IsWord% = -1 Else IsWord% = 0
End Function
"Words.txt" is a text file using CRLF's to end lines. All I had to do was insert a blank line at beginning of file so that the word "AA" could be verified as a word from the file.
This is way better IMHO than using a Random Access file!
Here is the file to run your own tests:
I fully agree with approach of Steve to load list in array, but that depends if you need/prefer efficiency and speed over short simple code. If you need to search 1000's of time, then better make a list array
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience

