ioliver Posted December 13, 2005 Share Posted December 13, 2005 Can anyone tell me if this is structured correctly? If StringInStr($line, "x-sender:") And StringInStr($line, "@microsoft.com") Or StringInStr($line, "x-sender:") And StringInStr($line, "@windows.com") Then Thanks, Ian Or, if it's not correct, how can I fix it? "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
MHz Posted December 13, 2005 Share Posted December 13, 2005 A suggestion If StringInStr($line, "x-sender:") Then If StringInStr($line, "@microsoft.com") Or StringInStr($line, "@windows.com") Then ; Do something. EndIf EndIf Link to comment Share on other sites More sharing options...
ioliver Posted December 13, 2005 Author Share Posted December 13, 2005 Thanks for the reply, but I'm not sure if that will work with my 'ExitLoop()' statement. Full Code: expandcollapse popup$dir = "Z:\JunkEmailArchive" FileChangeDir($dir) DirCreate($dir & "\SearchIMF-Complete") $output = FileOpen($dir & "\SearchIMF-Complete\SearchIMF.txt", 1); Opens for writing in Append mode FileWriteLine($output, @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN) SplashTextOn("Search IMF is working...", "Searching file: ", 350, 20, "", "", 22, "", "10") $search = FileFindFirstFile("*.EML") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $x = 0 $file = FileFindNextFile($search) If @error Then ExitLoop ; MsgBox(4096, "File:", $file); Uncomment to test script $EML = FileOpen($file, 0) ; Check if file opened for reading OK If $EML = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ControlSetText("Search IMF is working...", "", "Static1", "Searching File: " & $file) ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") And StringInStr($line, "@microsoft.com") Or StringInStr($line, "x-sender:") And StringInStr($line, "@windows.com") Then ; MsgBox(0, "Search IMF.au3 found an email from XP Systems", $file); Uncomment to test script $x = 1 ExitLoop Else $x = 0 EndIf WEnd FileClose($EML) If $x = 1 Then FileWriteLine($output, $file) FileMove($file, $dir & "\SearchIMF-Complete\" & $file) EndIf WEnd SplashOff() FileWriteLine($output, "") FileClose($output) Thanks, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
seandisanti Posted December 13, 2005 Share Posted December 13, 2005 Thanks for the reply, but I'm not sure if that will work with my 'ExitLoop()' statement. Full Code: expandcollapse popup$dir = "Z:\JunkEmailArchive" FileChangeDir($dir) DirCreate($dir & "\SearchIMF-Complete") $output = FileOpen($dir & "\SearchIMF-Complete\SearchIMF.txt", 1); Opens for writing in Append mode FileWriteLine($output, @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN) SplashTextOn("Search IMF is working...", "Searching file: ", 350, 20, "", "", 22, "", "10") $search = FileFindFirstFile("*.EML") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $x = 0 $file = FileFindNextFile($search) If @error Then ExitLoop ; MsgBox(4096, "File:", $file); Uncomment to test script $EML = FileOpen($file, 0) ; Check if file opened for reading OK If $EML = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ControlSetText("Search IMF is working...", "", "Static1", "Searching File: " & $file) ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") And StringInStr($line, "@microsoft.com") Or StringInStr($line, "x-sender:") And StringInStr($line, "@windows.com") Then ; MsgBox(0, "Search IMF.au3 found an email from XP Systems", $file); Uncomment to test script $x = 1 ExitLoop Else $x = 0 EndIf WEnd FileClose($EML) If $x = 1 Then FileWriteLine($output, $file) FileMove($file, $dir & "\SearchIMF-Complete\" & $file) EndIf WEnd SplashOff() FileWriteLine($output, "") FileClose($output) Thanks, Iani'd say to throw parentheses around the conditions.... If ( StringInStr($line, "x-sender:") And StringInStr($line, "@microsoft.com")) Or (StringInStr($line, "x-sender:") And StringInStr($line, "@windows.com")) Link to comment Share on other sites More sharing options...
MHz Posted December 13, 2005 Share Posted December 13, 2005 (edited) No problem just putting it in. Atleast I see none.expandcollapse popup$dir = "Z:\JunkEmailArchive" FileChangeDir($dir) DirCreate($dir & "\SearchIMF-Complete") $output = FileOpen($dir & "\SearchIMF-Complete\SearchIMF.txt", 1); Opens for writing in Append mode FileWriteLine($output, @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN) SplashTextOn("Search IMF is working...", "Searching file: ", 350, 20, "", "", 22, "", "10") $search = FileFindFirstFile("*.EML") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $x = 0 $file = FileFindNextFile($search) If @error Then ExitLoop ; MsgBox(4096, "File:", $file); Uncomment to test script $EML = FileOpen($file, 0) ; Check if file opened for reading OK If $EML = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ControlSetText("Search IMF is working...", "", "Static1", "Searching File: " & $file) ; Read in lines of text until the EOF is reached, or until "x-sender:" is found While 1 $line = FileReadLine($EML) If @error = -1 Then ExitLoop ; MsgBox(0, "Line read:", $line); Uncomment to test script If StringInStr($line, "x-sender:") Then If StringInStr($line, "@microsoft.com") Or StringInStr($line, "@windows.com") Then ; MsgBox(0, "Search IMF.au3 found an email from XP Systems", $file); Uncomment to test script $x = 1 ExitLoop Else $x = 0 EndIf EndIf WEnd FileClose($EML) If $x = 1 Then FileWriteLine($output, $file) FileMove($file, $dir & "\SearchIMF-Complete\" & $file) EndIf WEnd SplashOff() FileWriteLine($output, "") FileClose($output)Edit: As you can see, I only test StringInStr($line, "x-sender:") once in the loop, where as your original example checks it a second time to reach the same result. Edited December 13, 2005 by MHz 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