Sign in to follow this  
Followers 0
d0n

replace text

5 posts in this topic

$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

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

Read up on how to use StringReplace.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Yep :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
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
Sign in to follow this  
Followers 0