Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to format a While... Wend correctly?
#37
This file is so small, just keep it in a small corner of your memory
Makes life much easier also.

Takes 39ms on my older i5 system:
Code: (Select All)
Dim Shared words As String
words = _ReadFile$("Collins.txt")

Dim Junk(10) As String
Data cheese,dog,cat,elephant,rootbeer,house,food,drink,zebra,mouse
For i = 1 To 10
  Read Junk(i)
Next

t# = Timer(.001)
For i = 1 To 10
  Print Junk(i),
  def$ = FindWord(Junk(i))
  If def$ = "" Then
    Print "Word not found"
  Else
    Print def$
  End If
Next
t1# = Timer(.001)
Print Using "###.######## seconds to find #### words and definitions"; t1# - t#, i - 1
' 0.039 seconds

Function FindWord$ (wrd$)
  fpos& = InStr(words, UCase$(wrd$) + Chr$(9))
  If fpos& > 0 Then
    fpos& = fpos& + Len(wrd$) + 1
    eol& = InStr(fpos&, words, Chr$(13))
    FindWord$ = Mid$(words, fpos&, eol& - fpos&)
  End If
End Function
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply


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



Users browsing this thread: 10 Guest(s)