PassionTime2013 Posted August 8, 2013 Share Posted August 8, 2013 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, How can I do it for multiple string search. #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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 8, 2013 Moderators Share Posted August 8, 2013 PassionTime2013,Welcome to the AutoIt forum. But please pay attention to where you post - the "Developer Chat" section where you started this thread is not for general support questions. I have moved the thread for you, but would ask you to be more careful in future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PassionTime2013 Posted August 8, 2013 Author Share Posted August 8, 2013 (edited) Where U moved this thread can u mention url ... thanks Edited August 8, 2013 by PassionTime2013 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 8, 2013 Moderators Share Posted August 8, 2013 PassionTime2013, Where U moved this threadIf you do not know, then how did you find it to post? It is now in "General Help and Support" - your browser address bar will give you the URL if you really need it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PassionTime2013 Posted August 8, 2013 Author Share Posted August 8, 2013 (edited) This is the first time I entered this forum I have searched the all the tab Finally I got in "Developer Chat" section in that section I saw "New Post" then i posted my query, So u told that moved to thread side that's why I asked the Url, Edited August 8, 2013 by PassionTime2013 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 8, 2013 Moderators Share Posted August 8, 2013 PassionTime2013,Now you have found yourself again, would you care to explain more clearly what it is you want to do? It seems that you have a text file containing some of the headings from the AutoIt Help file and you want to print something from it after searching for a word. Is that a good summary? If you want to find out how many times a word is included in a text then use StringReplace - the count is returned in @extended as you can see here:#include <Constants.au3> $sString = "blah FRED blah blah blah FRED blah blah blah FRED blah blah blah blah FRED blah blah blah FRED blah blah blah" StringReplace($sString, "fred", "") $iCount = @extended MsgBox($MB_SYSTEMMODAL, "Count", "'Fred' appears " & $iCount & " times in the string")Is that any help? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PassionTime2013 Posted August 8, 2013 Author Share Posted August 8, 2013 (edited) Thanks for your reply Sorry I missed some words, Actually I wanted to search multiple strings in a text file which are "License", "Script Editors", "Controls","Window Info Tool (AU3Info)" and need to print that those particular lines Edited August 8, 2013 by PassionTime2013 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 8, 2013 Moderators Share Posted August 8, 2013 PassionTime2013,Then I suggest you put the search terms in an array so you can loop through them easily. Load the file into an array (_FileReadToArray) and then loop through that array checking each line for the required terms - if one of them is present, then copy that line to a new file (FileWriteLine). When all is done you will have a file containing the required lines which you can print at your leisure.Give it a go and see how you get on - you know where we are if you run into problems. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now