How to format a While... Wend correctly? - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: How to format a While... Wend correctly? (/showthread.php?tid=2466) |
RE: How to format a While... Wend correctly? - SMcNeill - 03-01-2024 words = CHR$(10) + _ReadFile("Collins.txt") RE: How to format a While... Wend correctly? - bplus - 03-01-2024 (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. RE: How to format a While... Wend correctly? - Pete - 03-02-2024 WHILE "Pete" > "$teve" PRINT "Help, I'm stuck in an infinite loop!" WEND Pete RE: How to format a While... Wend correctly? - PhilOfPerth - 03-02-2024 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) RE: How to format a While... Wend correctly? - bplus - 03-02-2024 @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. |