Well today I ran the code against 900 lines, and for each lines, it looks for a
keyword match in another file of 20000 lines!
So to speed it up, I first load the 20000 "keywords" into an array (which
strangely takes a lot of time on its own, maybe close to 1 minute):
Dim KeywordsCount
KeywordsCount = KeywordsDoc.linesCount
Dim KeywordsList()
redim KeywordsList(KeywordsCount)
For j = 1 To KeywordsCount
KeywordsDoc.caretY(j)
KeywordsList(j-1) = KeywordsDoc.lineText
Next
You're right that there might be a better way to do it!
Then I check each line of my document against this list:
For i = 1 To ProcessDoc.linesCount
ProcessDoc.caretY(i)
ProcessString = ProcessDoc.lineText
IsOK = False
For j = 1 To KeywordsCount
If InStr(ProcessString, KeywordsList(j-1)) > 0 Then
IsOK = True
Exit For
End If
Next
If Not IsOK Then ProcessDoc.lineText(vbNullString)
Next
Since I only read each line once in this second section, I couldn't see a
benefit into loading the contents into memory.
--
<http://forum.pspad.com/read.php?2,65099,65105>
PSPad freeware editor http://www.pspad.com