theguy0000 Posted February 25, 2006 Share Posted February 25, 2006 #include <File.au3> MsgBox(0, "whats", _FileFindString("C:\test.txt", "whats")) MsgBox(0, "are", _FileFindString("C:\test.txt", "are", 2)) MsgBox(0, "dude", _FileFindString("C:\test.txt", "dude", 3)) When I run this, it does absolutely nothing at all, and ends immediately. No message boxes, no errors, nothing. It just exists. Here is _FileFindString: ;$iMode - ; 1 - Beginning of line (default) ; 2 - Anywhere in line ; 3 - Whole line Func _FileFindString($zFile, $sSearch, $iMode=1) If $iMode <> 1 Or $iMode <> 2 Or $iMode <> 3 Then SetError(-3) Return -3 EndIf If Not FileExists($sPath) Then SetError(-1) Return -1 EndIf If IsString($zFile) Then $handle = FileOpen($sPath, 0) Else $handle = $zFile If $handle = -1 Then SetError(-2) Return -2 EndIf For $i=1 To _FileCountLines($sPath) If $iMode = 1 Then If StringInStr(FileReadLine($handle, $i), $sSearch) = 1 Then Return $i ElseIf $iMode = 2 Then If StringInStr(FileReadLine($handle, $i), $sSearch) Then Return $i ElseIf $iMode = 3 Then If FileReadLine($handle, $i) = $sSearch Then Return $i EndIf Next Return 0 EndFunc What is wrong here? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
ChrisL Posted February 25, 2006 Share Posted February 25, 2006 (edited) $sPath?? didn't make sense so changed to $zFile Commented out the else because that didn't make sense either. I'm not really sure what your expecting to get back from this, you will only ever get a number back based on the For count. expandcollapse popup#include <File.au3> MsgBox(0, "whats", _FileFindString("C:\test.txt", "whats")) MsgBox(0, "are", _FileFindString("C:\test.txt", "are", 2)) MsgBox(0, "dude", _FileFindString("C:\test.txt", "dude", 3)) ;$iMode - ; 1 - Beginning of line (default) ; 2 - Anywhere in line ; 3 - Whole line Func _FileFindString($zFile, $sSearch, $iMode=1) If not $iMode > 0 or $iMode > 3 Then SetError(-3) Return -3 EndIf If Not FileExists($zFile) Then SetError(-1) Return -1 EndIf If IsString($zFile) Then $handle = FileOpen($zFile, 0) ;;;;Else $handle = $zFile If $handle = -1 Then SetError(-2) Return -2 EndIf For $i=1 To _FileCountLines($zFile) If $iMode = 1 Then If StringInStr(FileReadLine($handle, $i), $sSearch) = 1 Then Return $i ElseIf $iMode = 2 Then If StringInStr(FileReadLine($handle, $i), $sSearch) Then Return $i ElseIf $iMode = 3 Then If FileReadLine($handle, $i) = $sSearch Then Return $i EndIf Next Return 0 EndFunc Edited February 25, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
theguy0000 Posted February 25, 2006 Author Share Posted February 25, 2006 oh, right. Thanks. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
ChrisL Posted February 25, 2006 Share Posted February 25, 2006 hang on I got this line "If not $iMode > 0 or $iMode > 3 Then" arse about face first time round. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
theguy0000 Posted February 25, 2006 Author Share Posted February 25, 2006 (edited) what do you mean? edit: oh I see. thanks. Edited February 25, 2006 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN 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