123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|497|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Dictionary Search

Wed, 19 Mar 2025, 17:39
dna

Dictionary Search


F2 Is the dictionary. W$ is he word read from it. ZZ$ is the line to be scanned.



I'm trying to get this code to scan a lin for words that are in my dictionary. It does it once but then exits.

I cannot get his code to go through my dictionary. It's supposed to take a word from the dictionary and scan a line to see if it's inside the line. It does it once and then no more even though there's a while wend

-=-=-
DNA
Thu, 20 Mar 2025, 03:05
Dan
Because the Eof(F2) is in the while loop, it exits when the end of the file is hit.
Thu, 20 Mar 2025, 03:34
Jayenkai
Honestly, there's SO many issues here..

Like how you're reading from a file.. But you never (I don't believe) reset the file's read position to the start of the file, so it only ever resumes from where it was.

Also, the fact that you're constantly reading from a file at all. That really should be in memory in an array.

Also, the fact that you're using far too many String commands at once and Blitz2D/3D/Max is actually pretty slow at doing string commands.

1. Load the dictionary into memory at the start of your project.
Open File, Read word$, Upper$(word$), Add to Dictionary$[] array
Then leave the Dictionary$ intact so you can make use of it as you go, instead of constantly using files all the time. File access might be faster in our SSD-fuelled age, but that's still a lot of disk access, and that's never a good thing.

2. Make a Function to scan for words.
Function ScanWords(TextToScan$)
> > TextToScan$=Upper$(TextToScan$)
> > Now do the scan, so that you aren't constantly needing to Upper$ all the time.
>>>> For n=0 to DictionaryLength : etc.
EndFunction

Both of these should help speed things up immensely, and should help you figure out where any additional issues might be.

You can also try converting things to numbers, because numbers are MUCH quicker than strings in Blitz, but that's a whole other kettle of fish, and it's much more complicated to do.

-=-=-
''Load, Next List!''
Thu, 20 Mar 2025, 03:35
Dan
Here is a quick, modified, version of your file, which seeks for a word and displays if its in the dictionary file: