d0n Posted April 22, 2007 Share Posted April 22, 2007 $action = "test" ;$a = 0 ;While $a <= 1000 $Contents = FileRead("C:\Documents and Settings\Administrator\My Documents\logs\21-Apr-2007.txt") $location = StringInStr($contents, $action) StringReplace($contents, $location, "abca") If $location Then MsgBox(0,"Found","The search string is in the log") ;$a = $a + 1 ;sleep (1000) ;WEnd can someone tell me why it wont replace test with abca?? the msgbox pops up and tell me its there but wont replace ty Link to comment Share on other sites More sharing options...
BrettF Posted April 22, 2007 Share Posted April 22, 2007 $action = "test" ;$a = 0 ;While $a <= 1000 $Contents = FileRead("C:\Documents and Settings\Administrator\My Documents\logs\21-Apr-2007.txt") $location = StringInStr($contents, $action) StringReplace($contents, $location, "abca") If $location Then MsgBox(0,"Found","The search string is in the log") ;$a = $a + 1 ;sleep (1000) ;WEnd can someone tell me why it wont replace test with abca?? the msgbox pops up and tell me its there but wont replace ty I think your missing a very important part To rewrite it in the file. Check out FileWrite. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
herewasplato Posted April 22, 2007 Share Posted April 22, 2007 Read up on how to use StringReplace. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
MHz Posted April 22, 2007 Share Posted April 22, 2007 (edited) Read up on how to use StringReplace.What? Like StringReplace() actually returns something to use. $action = "test" ;$a = 0 ;While $a <= 1000 $Contents = FileRead("C:\Documents and Settings\Administrator\My Documents\logs\21-Apr-2007.txt") If Not @error Then $location = StringInStr($contents, $action) $value = StringReplace($contents, $location, "abca") If $location Then MsgBox(0,"Found " & @extended & " times", "The search string is in the log" & @CRLF & $value) EndIf EndIf Edit: Added code Edited April 22, 2007 by MHz Link to comment Share on other sites More sharing options...
herewasplato Posted April 23, 2007 Share Posted April 23, 2007 What? Like StringReplace() actually returns something to use. ...Yep :-) [size="1"][font="Arial"].[u].[/u][/font][/size] 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