Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have file called Test.txt contains

Introduction
License
Installation Directory
Frequently Asked Questions (FAQ)
Credits
History ChangeLog
History of and Developers
Running Scripts
Script Editors
Compiling Scripts
Window Info Tool (Info)
Window Titles and Text (Basic)
Window Titles and Text (Advanced)
Controls
Running under normal user

I wanted get multiple string "License", "Script Editors", "Controls","Window Info Tool (AU3Info)" as print ouput with searched lines using autoit

below code I can search only one time

#include <File.au3>
#include <array.au3>
$file = @ScriptDir & "\file.txt"
$search = "word"

If FileExists($file) Then
    $contents = FileRead($file)
    If @error Then
        MsgBox(0, 'File Error', $file & ' could not be read.')
    Else
        For $i = 1 To $count
            If StringInStr($contents, $search) Then        
                MsgBox(0, 'found', $file & ' does contain the text "' & $search & '"')
            Else
                MsgBox(0, 'Not', $file & ' does NOT contain the text "' & $search & '"')
            EndIf
        Next
    EndIf
EndIf
share|improve this question
That example code looks pretty familiar... – Johannes Thomas Meyer 22 hours ago
And it doesn't even make sense... Why do you copy non-working code as an example? If you use a For-loop to iterate from 1 to $count without $count being initialized, you will end up with nothing... as it results to 0, so the loop won't even run once... – Johannes Thomas Meyer 22 hours ago
Finally you didn't even change the "file.txt" in the example to your desired "test.txt" as stated in your question above... – Johannes Thomas Meyer 22 hours ago
Not to be offensive, but your abilities for abstraction seem to be improvable. Try to get a solution by yourself... and if you get stuck somewhere ask something specific. But you need a little bit of analytical abilities to do some programming. Please prove somehow, you have these... – Johannes Thomas Meyer 22 hours ago
A good thing: you replaced "str" from your previous question with "word"... but the #include <array.au3> is completely unnecassary. – Johannes Thomas Meyer 22 hours ago
add comment (requires an account with 50 reputation)

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.