LerN Posted April 22, 2017 Posted April 22, 2017 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.
genius257 Posted April 22, 2017 Posted April 22, 2017 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. LerN 1 To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
LerN Posted April 22, 2017 Author Posted April 22, 2017 i need something to replace in the section it self not searching in all the file for "Active" and that's the problem
Developers Jos Posted April 22, 2017 Developers Posted April 22, 2017 That is what the code does posted by @genius257, just replace the value for case in section [name2]. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
LerN Posted April 22, 2017 Author Posted April 22, 2017 (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 April 22, 2017 by LerN
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now