Sign in to follow this  
Followers 0
kristoff

replace string

4 posts in this topic

Hi everybody,

I'm currently working on a project to deploy an aplication to dedicated targets located in txt file.

Once the software is pushed to the server, I have to modify the unattended file.

The problem, is that the line order can't be changed, if it is, the application is stucked. Using iniwrite will append at the end of each ection. For instance, I need to change the line #30 (servename=Default to servername=StringLower(@ComputerName) ), that's ok but not at line 30 :D

If someone can point me or help me to sort out this, I'll be grateful !!

TIA gang

Share this post


Link to post
Share on other sites



Instead of using the IniWrite command, try reading it as a standard file using FileRead or the UDF to read a file into an array (each line as an element.) You could do that, search for the ini section, then key you're looking for. Change that element of the array, and then write the file back from your modified array.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Using iniwrite will append at the end of each ection.

.. this is true only if the key does not already exist. :huh2:

If the key exists already, then the line is updated wherever it is .. try this and you'll see that the position of key01 doesn't change with the second assignment:

INIwrite("_xxx.ini","section","key01","aaaaa")
    INIwrite("_xxx.ini","section","key02","aaaaa")
    INIwrite("_xxx.ini","section","key03","aaaaa")
    INIwrite("_xxx.ini","section","key01","bbbbb");--> key01 stays where it is

exit

HTH :D

Edit: elucidation

Edited by trids

Share this post


Link to post
Share on other sites

Hmmm !!

True ;-)

My errors was ...I was deleted the line before updating it !! :ph34r:

Sometime I'm wrong...I don't why :(

Cheers men

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0