Jump to content

Recommended Posts

Posted

Hi,
iam trying to replace string in file contains strings like this :
 

[name1]
Case = Active
[name2]
Case = Active
[name3]
Case = Done
[Name4]
Case = Done

If i used:

$readCaseFile = IniRead("Names.txt","name2","Case","")
_ReplaceStringInFile("Names.txt",$readCaseFile,"Replaced",0,0)

it will replace the first Active that in section name1 while i wanted it to replace in the section name2
so have u any idea ?
if u don't understand tell me and i can explain more, thanks.
 

Posted

Hi @LerN.

Doesn't IniWrite fulfill your problem?

$readCaseFile = IniRead("Names.txt","name2","Case","")
IniWrite("Names.txt", "name2", "Case", "Replaced")

If not, _ReplaceStringInFile is troublesome, if you do not first find the precise point of the match, in case of multiple matches.

Posted

i need something to replace in the section it self not searching in all the file for "Active" and that's the problem

Posted (edited)
Just now, Jos said:

That is what the code does posted by @genius257, just replace the value for case in section [name2].

Jos

My internet isn't good , i didn't see his comment until now and the problem fixed 
i wrote my comment before him but bec, the internet posted after he replayed thanks both :)

Edited by LerN

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