Jump to content

Recommended Posts

Posted

Hi

i 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 = 1

this is third line = 1

need to look like that (remove the ";")

this is test line = 1

this is second line = 1

"If the facts don't fit the theory, change the facts." Albert Einstein

Posted

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

Posted

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 :D)

Posted

i try that but obviously i`m way off! :D

$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

Posted

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
Posted (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 by dbzfanatic
Posted

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? :D

"If the facts don't fit the theory, change the facts." Albert Einstein

Posted

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.

Posted

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

Posted

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

Posted

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

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
×
×
  • Create New...