Jump to content

replace text


d0n
 Share

Recommended Posts

$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

$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. :shocked:
Link to comment
Share on other sites

Read up on how to use StringReplace.

What? Like StringReplace() actually returns something to use. :shocked:

$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 by MHz
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...