Jump to content

Recommended Posts

Posted

I want to replace part of a line of text

For example

this is line 1

this is line 2

this is line 3

this is line 23 the number is NO

this is line 24 the number is NO

this is line 25

this is line 33 the number is NO

The number you require is NO

That annoying number you want is NO

Please phone NO for assistance

How do i replace 'NO' with say '12345678' throughout the text file

hope this make sense :ph34r:

Posted

Scan the entire file line by line, set variable to the line contents

$text = StringReplace("<line contents>", "NO", "123456789")

Write string back to the line you read out of.

Sitting comfortably behind the code.

Posted (edited)

You might want to check the help file for anything that contains "file" or "write" in its name or ask about the specific problems you have.

Edited by sugi
Posted

thanks i figured it out after i spent the time to look at it properly

_FileReadToArray( "c:\list.txt", $temp )    

For $n = 1 to $temp[0]

    $temp[$n]=  StringReplace($temp[$n],$MidToChange, Guiread($MID))
     FileWrite("tempfilename.txt",$temp[$n])
    
    IF $n < $temp[0] THEN FileWrite("tempfilename.txt",@lf)

Next

FileCopy("tempfilename.txt","c:\list.txt",1)
FileDelete("tempfilename.txt")

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
  • Recently Browsing   0 members

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