Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/21/2012 in all areas

  1. If you ran my script as it is and you just renamed your text files to match the the filenames in the script, and it worked for you then the lines you edited in the script are most likely the problem. I noticed you don't have quotes surrounding your new names. Did you forget them in the script? However; I noticed that my script terminated before the last line in the "text cluster file" was checked. Should be fixed in the script below. #include <File.au3> #include <Misc.au3> Opt("MustDeclareVars", 1) Global $hDLL = DllOpen("user32.dll") Global $keywordsFile = 'keywords.txt' Global $textCluster = 'text.txt' Global $iFile, $aKeyWords, $iNumOfLines, $hResultFile Global $i, $ii, $iCount = 1, $sRet ;Check for keywords file If Not FileExists($keywordsFile) Then MsgBox(48, 'ERROR', 'Keywords file not found.' & @CRLF& 'Program Terminated.') Exit EndIf ;Check for text cluster file If Not FileExists($textCluster) Then MsgBox(48, 'ERROR', 'Text Cluster file not found.' & @CRLF& 'Program Terminated.') Exit EndIf $iFile = _FileReadToArray($keywordsFile, $aKeyWords) If $iFile = 0 Then MsgBox(48, 'ERROR', 'Error: ' & @error & @CRLF & 'Check Autoit help file for _FileReadToArray() function') Exit EndIf $hResultFile = FileOpen('result.txt',1) $iNumOfLines = _FileCountLines($textCluster) For $i = 1 To $iNumOfLines If _IsPressed('1b', $hDLL) Then ; Press the escape key to quit ExitLoop EndIf $sRet = FileReadLine($textCluster, $iCount) For $ii = 1 To UBound($aKeyWords, 1) -1 If StringInStr($sRet, $aKeyWords[$ii], 2, -1) Then FileWrite($hResultFile, $sRet & @CRLF) EndIf Next If $iCount = $iNumOfLines Then ExitLoop EndIf $iCount = $iCount + 1 Next FileClose($hResultFile) DllClose($hDLL) Exit
    1 point
  2. Maybe this will work for you. I tested it with a short keyword list, and a small "text cluster file". It's probably not perfect... #include <File.au3> #include <Misc.au3> Opt("MustDeclareVars", 1) Global $hDLL = DllOpen("user32.dll") Global $keywordsFile = 'keywords.txt' Global $textCluster = 'text.txt' Global $iFile, $aKeyWords, $iNumOfLines, $hResultFile Global $i, $ii, $iCount = 1, $sRet $iFile = _FileReadToArray($keywordsFile, $aKeyWords) If $iFile = 0 Then MsgBox(48, 'ERROR', 'Error: ' & @error & @CRLF & 'Check help file for _FileReadToArray() function') Exit EndIf $hResultFile = FileOpen('result.txt',1) $iNumOfLines = _FileCountLines($textCluster) For $i = 1 To $iNumOfLines If _IsPressed('1b', $hDLL) Then ; Press the escape key to quit ExitLoop EndIf If $iCount = $iNumOfLines Then ExitLoop EndIf $sRet = FileReadLine($textCluster, $iCount) For $ii = 1 To UBound($aKeyWords) -1 If StringInStr($sRet, $aKeyWords[$ii], 2) Then FileWrite($hResultFile, $sRet & @CRLF) EndIf Next $iCount = $iCount + 1 Next FileClose($hResultFile)
    1 point
  3. Something like: #include $string = "My line contains the word MKISH" $string2 = "MKISH MKISH everywhere" $string1 = "NO word" FileWrite("example.txt", $string & @crlf & $string2 & @CRLF & $string1) msgbox(64, "", "Example txt file created. I will search for 'MKISH'") For $i = 1 to Int(_FileCountLines("example.txt")) If StringInStr(FileReadLine("example.txt", $i), "MKISH") then FileWrite("MKISH.txt", FileReadLine("example.txt", $i) & @crlf) Next Change the word "MKISH" to whatever your search is...
    1 point
×
×
  • Create New...