Guest Posted August 17, 2012 Share Posted August 17, 2012 (edited) Hello,Melba23 gave me here:This search code:#include <File.au3> ; Read the file into an array Global $aLines _FileReadToArray("test.txt", $aLines) ; Loop through the array looking for "$" For $i = 1 To $aLines[0] If StringInStr($aLines[$i], "$") Then MsgBox(4096, "", "Found $ at line: " & $i) Else MsgBox(4096, "", "Not in: " & $i) EndIf NextExcellent code .. I'm still trying to learn it.But it fails in this case:test1 test2 te st3 test4If I try to search for the test1 / test2 / test4So it works well.but not if i try to search for test3 .I understand why it does not work.But in my case I have to make it work.Thanks for helpers! Edited August 17, 2012 by Guest Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 17, 2012 Moderators Share Posted August 17, 2012 gil900,It is hardly surprising that the code I gave you in the other thread does not work for "test3" as it is split over a line-break! Before I start thinking of how we might meet your new requirements, which line number do you want returned for values like test3 that exist on 2 lines - 1 or 2? 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...
Guest Posted August 17, 2012 Share Posted August 17, 2012 Clear why it does not work. But this idea - it has to deal with line-break. I did not understand what you are asking me .. I just need it to deal with line-break This is my only requirement. With the other things I'll deal (I think). It's just the part I do not know how to do .. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 17, 2012 Moderators Share Posted August 17, 2012 gil900, Try this: expandcollapse popup#include <File.au3> ; Read the file into an array Global $aLines _FileReadToArray("test.txt", $aLines) ; And into a variable $sFile_Text = FileRead("test.txt") ; Remove all @CR and @LF $sFile_Text = StringRegExpReplace($sFile_Text, "[rn]", "") ConsoleWrite($sFile_Text & @CRLF) While 1 $sSearch_String = InputBox("Input search string", "Leave empty to exit") If $sSearch_String = "" Then ExitLoop EndIf ; Loop through the array looking for search string $fFound = False For $i = 1 To $aLines[0] If StringInStr($aLines[$i], $sSearch_String) Then $fFound = True MsgBox(4096, "", "Found " & $sSearch_String & " at line: " & $i) EndIf Next ; If not found then we look for the string in the whole file text If Not $fFound Then $iLocation = StringInStr($sFile_Text, $sSearch_String) ; If it is found then work out the line If $iLocation Then $iCharCount = 0 For $i = 1 To $aLines[0] $iCharCount += StringLen($aLines[$i]) If $iCharCount > $iLocation Then MsgBox(4096, "", "Found " & $sSearch_String & " at line (split): " & $i) ExitLoop EndIf Next EndIf EndIf WEnd All clear? 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...
Guest Posted August 17, 2012 Share Posted August 17, 2012 gil900, Try this: expandcollapse popup#include <File.au3> ; Read the file into an array Global $aLines _FileReadToArray("test.txt", $aLines) ; And into a variable $sFile_Text = FileRead("test.txt") ; Remove all @CR and @LF $sFile_Text = StringRegExpReplace($sFile_Text, "[rn]", "") ConsoleWrite($sFile_Text & @CRLF) While 1 $sSearch_String = InputBox("Input search string", "Leave empty to exit") If $sSearch_String = "" Then ExitLoop EndIf ; Loop through the array looking for search string $fFound = False For $i = 1 To $aLines[0] If StringInStr($aLines[$i], $sSearch_String) Then $fFound = True MsgBox(4096, "", "Found " & $sSearch_String & " at line: " & $i) EndIf Next ; If not found then we look for the string in the whole file text If Not $fFound Then $iLocation = StringInStr($sFile_Text, $sSearch_String) ; If it is found then work out the line If $iLocation Then $iCharCount = 0 For $i = 1 To $aLines[0] $iCharCount += StringLen($aLines[$i]) If $iCharCount > $iLocation Then MsgBox(4096, "", "Found " & $sSearch_String & " at line (split): " & $i) ExitLoop EndIf Next EndIf EndIf WEnd All clear? M23 Seems unclear. But I'll try to figure it out. Thank you! I check it Link to comment Share on other sites More sharing options...
Guest Posted August 17, 2012 Share Posted August 17, 2012 It works! Thank you! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 17, 2012 Moderators Share Posted August 17, 2012 gil900,Seems unclear. But I'll try to figure it outJust ask if you need any more 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...
Moderators Melba23 Posted August 17, 2012 Moderators Share Posted August 17, 2012 gil900, If the text is in memory does it still have the line breaks? How is the text generated? What exactly are you trying to do? A little more information would be useful - I hate producing example after example because the OP does not explain the problem in enough detail at first. 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...
Moderators Melba23 Posted August 18, 2012 Moderators Share Posted August 18, 2012 gil900,And you think I am going to help with a script searching for "teencore Hustler Videosz"? Not a chance - and do not try opening another thread with a different set of search words either. 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