03-01-2024, 03:10 PM
words = CHR$(10) + _ReadFile("Collins.txt")
How to format a While... Wend correctly?
|
03-01-2024, 03:10 PM
words = CHR$(10) + _ReadFile("Collins.txt")
(03-01-2024, 03:10 PM)SMcNeill Wrote: words = CHR$(10) + _ReadFile("Collins.txt") of course! so simple rechecking now... This is working well for the few tests I gave it: Code: (Select All) Dim Shared words As String It still can't find Steve.
b = b + ...
03-02-2024, 03:24 AM
WHILE "Pete" > "$teve"
PRINT "Help, I'm stuck in an infinite loop!" WEND Pete
03-02-2024, 03:51 AM
(This post was last modified: 03-02-2024, 03:55 AM by PhilOfPerth.)
I haven't analyzed all those listings, but this seems to me to be the simplest search:
Code: (Select All) Open "RA.txt" For Random As #1 Len = 11 ... using the binary search that bplus showed (amended/maybe corrupted a bit). Works for me, anyway, including AA, ZEBRA, ZZZS and CAT! (RA.txt is an RA file with len = 11)
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
@PhilOfPerth I have tested the method above and have to say I have been converted.
1. you don't have to do anything to Collins.txt but you could add an extra line first, no big deal if you don't. So no 2 RA files needed nor do you have to keep at least one RA file open while the program is running, not the greatest to have a file open when you quit though unlikely to do any damage. The entire file is loaded into a very long string and done in one giant gulp! You now have the contents accessible by RAM not file access, much faster. 2. Just look how it finds a word, it uses INSTR() ONCE because we enclose the word with a chr$(10) at front and a Chr$(9) on end to guarantee the words we find are the first on any line of Collins.txt file. It does use INSTR() again just to find the end of that particlar line. So there is no playing of the guessing game that we do with an RA file. It's pretty cool efficiency wise.
b = b + ...
|
« Next Oldest | Next Newest »
|