Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to format a While... Wend correctly?
#42
(03-01-2024, 03:10 PM)SMcNeill Wrote: words = CHR$(10) + _ReadFile("Collins.txt")

of course! so simple Smile rechecking now...

This is working well for the few tests I gave it:
Code: (Select All)
Dim Shared words As String
'  be sure to to add Chr$(10) to assure catching the first word from dictionary
words = Chr$(10) + _ReadFile$("Collins.txt") ' Steve fix to catch first word at line start

Do
    Input "Enter word to lookup "; lookup$
    result$ = FindWord$(lookup$)
    If result$ = "" Then Print lookup$; " Not Found." Else Print result$
    Print
Loop Until lookup$ = ""

Function FindWord$ (wrd$) ' thanks mdijkens and Steve fix to assure start of line
    fpos& = InStr(words, Chr$(10) + UCase$(wrd$) + Chr$(9)) ' Steve fix to catch first word at line start
    If fpos& > 0 Then
        fpos& = fpos& + Len(wrd$) + 2
        eol& = InStr(fpos&, words, Chr$(13))
        FindWord$ = Mid$(words, fpos&, eol& - fpos&)
    End If
End Function

It still can't find Steve. Smile
b = b + ...
Reply


Messages In This Thread
RE: How to format a While... Wend correctly? - by bplus - 03-01-2024, 07:21 PM



Users browsing this thread: 1 Guest(s)