shay Posted September 1, 2009 Share Posted September 1, 2009 Hii wont to remove specify character from 2 lines in INI file,i try StringReplace but i don't think that this is the right command to use.the line look like that:;this is test line = 1;this is second line = 1this is third line = 1need to look like that (remove the ";")this is test line = 1this is second line = 1 "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 1, 2009 Share Posted September 1, 2009 StringReplace should work. How did you use it? Give us the script you wrote so we can help more. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
99ojo Posted September 1, 2009 Share Posted September 1, 2009 StringReplace should work. How did you use it? Give us the script you wrote so we can help more.Hi,have a look at _ReplaceStringInFile.;-))Stefan Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 1, 2009 Share Posted September 1, 2009 They're essentially the same and the poster said they'd used it but they didn't think it was the right function. It would work if done properly but _ReplaceStringInFile probably would be easier for the poster (or harder depending ) Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
shay Posted September 1, 2009 Author Share Posted September 1, 2009 i try that but obviously i`m way off! $path2 = "root to file\test.ini" $line = IniReadSection ( $path2, "general") StringReplace( ";", "{DELETE}",2) "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
Manjish Posted September 1, 2009 Share Posted September 1, 2009 Dunno why string replace shouldn't work.. $line=";this is line 1" MsgBox(4096,"",StringReplace($line,";","")) [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 1, 2009 Share Posted September 1, 2009 (edited) Just in case you can't draw what you need from Manjish's example (don't know why you wouldn't be able to but some people can't) you have StringReplace( ";", "{DELETE}",2) when you need StringReplace($line1,";","") . I had a feeling your implementation was wrong so that's why I asked. Hope the info you got here helps. Edited September 1, 2009 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
shay Posted September 1, 2009 Author Share Posted September 1, 2009 Ok now i think i know what is wrong i need to read a INI section using "IniReadSection" then apply "StringReplace($line1,";","",2)" then write to the INI file but if i`ll write to file i will have duplicate Sections, no? "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
dbzfanatic Posted September 1, 2009 Share Posted September 1, 2009 You won't have duplicates if you overwrite only the line you want. For your needs it would probably be easier to use _ReplaceStringInFile() as stated above. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
shay Posted September 1, 2009 Author Share Posted September 1, 2009 ok i`m able to do this $s = FileOpen("c:\test.ini",0 ) $file = FileRead ($s,100) MsgBox(0, "test",StringReplace($file,";","",2)) i unable to do that with"IniReadSection" command, i prefer doing this with "IniReadSection" so the code will be more resistant to any changes in the INI file. any idea? "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
99ojo Posted September 1, 2009 Share Posted September 1, 2009 ok i`m able to do this $s = FileOpen("c:\test.ini",0 ) $file = FileRead ($s,100) MsgBox(0, "test",StringReplace($file,";","",2)) i unable to do that with"IniReadSection" command, i prefer doing this with "IniReadSection" so the code will be more resistant to any changes in the INI file. any idea? Hi, #include <File.au3> _ReplaceStringInFile ("c:\test.ini",";","") ; all ; are replaced by empty string ;-)) Stefan Link to comment Share on other sites More sharing options...
shay Posted September 1, 2009 Author Share Posted September 1, 2009 thanks i use the _ReplaceStringInFile. i change the #File.au3 so it will run only on the first string, i Thoth that i can use the IniReadSection, that way if the INI file will be changed my script wont be effacted "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
99ojo Posted September 1, 2009 Share Posted September 1, 2009 Hi, IniReadSection doesn't read lines with a ; at the beginning. So function will only read line 3 in. ;-(( Stefan Link to comment Share on other sites More sharing options...
jvanegmond Posted September 1, 2009 Share Posted September 1, 2009 When you read the ini into your program, all lines with comments are ignored because they're not useful for your program. If you want to replace ; characters in a file, then you should use the examples posted above. Forget about IniRead... github.com/jvanegmond Link to comment Share on other sites More sharing options...
shay Posted September 1, 2009 Author Share Posted September 1, 2009 OK thx you all!!! love this forum! "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
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