Jump to content

StringReplace?


Recommended Posts

Please Help! Something that was supposed to be quite simple just turned out to be "impossible". I just can't get my head around this.

My problem: I've got a string in a text file that I want to find and replace but it seems impossible. I can't find a string in a text file without opening the file as read only and if I open the file in write mode then I can't do a FileRead and only have 2 write options:

1. Append to the end of the file

2. Overwite the entire contents of the file.

I'm obviously missing something?

This is what I've got so far:

if FileExists ($FileName) Then

$file = FileOpen($FileName, 0)

if Not($file = -1) Then

While 1

$line = FileReadLine($file)

;Msgbox (0, 'line', $line)

If @error = -1 Then ExitLoop

$s = StringInStr($line, $Customstr)

if not($s=0) Then

MSGBOX (0, "Match Found", $line)

;Now replace the string...?????

EndIf

Wend

EndIf

FileClose($file)

EndIf

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...