Jump to content

Recommended Posts

Posted

I have this very simple but possibly quite complicated idea for a program. It is kind of a rip of the "Find" function used in many programs and really is in a way a re-create. The problem is it take ages for the program to process the information and that is on a good PC (i5-6600, 16GB DDR4, SSD). The question, why? Why cant it work just like the find function, and how does the find function in many programs work so efficiently?

Website for the words file as only allowed 4MB and it is 5MB :rolleyes:https://raw.githubusercontent.com/dwyl/english-words/master/words.txt 

Code:

#include <File.au3>

$Letters = InputBox("Letters","Input the letters you have.","","")
If @error Then Exit

$File_Words = @ScriptDir&"\words.txt"
$Words = "Words:"

$Amount = StringLen($Letters)

$lines = _FileCountLines($File_Words)
ProgressOn("Searching...","","")
ProgressSet(0)

For $i = 0 To $Amount
    $string = StringTrimRight($Letters,$i)
    For $j = 1 To $lines
        ProgressSet($lines/$j)
        If FileReadLine($File_Words,$j) = $string Then
            $Words = $Words&@CRLF&$string
        EndIf
    Next
Next
MsgBox(0,'',$Words)

 

Posted

@kingjacob90 , this is what I prefer. Simple code to do weird stuff... you dont have to be complex in you code. 

Well done on this one... 

btw, you have another user named @kingjacob280.. with the same profile picture and everything... that also you? 

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Posted (edited)
  On 10/11/2018 at 10:01 AM, kingjacob90 said:

Why cant it work just like the find function

Expand  

Becose you're not using String compare

 

  On 10/11/2018 at 10:01 AM, kingjacob90 said:

and how does the find function in many programs work so efficiently?

Expand  

They just do string comparaison on some simple sub string with maybe 500 - 1000 Entry

Dont forget that a page with 1 500 words can have 200 different words only... maybe less... 

 

If you got a file with all existing words. 200 000 Words for english language. 

 

It will take a bit more time to compare :yawn: ... Pretty obvius ? (particulary if you want to have all know words with same characters. that's more calcul./././ )

 

 

.... and say the real purpose of your script. 

What do you want to do exactly ? Find all possible words of given characters to be able to play scrabble online  ?

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

  Reveal hidden contents

 

Posted

I think it would be faster if you read all lines to an array and then work with it instead of reading line by line from the file for each query you make.

Also, maybe ditch the string trim, and use stringinstr.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...