Berti Posted September 24, 2005 Share Posted September 24, 2005 Hi, I've a lot of different textfiles, which looks like ini-file. (main.cfg). In this main.cfgs are a lot of sections ([sectionA.0], [section A.1], ..., [sectionB.0] and so on). Each main.cfg has one ore more A-sections. I want to add one ore more (up to 10) new A-sections after the last A-section in the main.cfg. The new A-sections should contain the same keys (with different values of course) as the existing A-section. So I think I've to count the A-sections first (should be no problem). But what to do then? Copy and rename the last A-section (I don't know how)? Create a new A-section? How can I insert the keys then? Or is it better (easier) to create a second file with the A-sections prepared to insert? Nevertheless, they must be renamed because I don't know how many A-sections are in the main.cfg. Thnx for help Berti Link to comment Share on other sites More sharing options...
Valuater Posted September 24, 2005 Share Posted September 24, 2005 (edited) just use this format IniWrite ( "filename", "section", "key", "value" ) and it will create the new section name and place the value that you want 8) Edited September 24, 2005 by Valuater Link to comment Share on other sites More sharing options...
Danny35d Posted September 24, 2005 Share Posted September 24, 2005 Look at the help files.....Writes a value to a standard format .ini file.IniWrite ( "filename", "section", "key", "value" )Parameters:filename The filename of the .ini file. section The section name in the .ini file. key The key name in the in the .ini file. value The value to write/change. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Berti Posted September 24, 2005 Author Share Posted September 24, 2005 Oh, I know the IniWrite command. One of the problems is to create a new section b e t w e e n two other sections and not at the end of the file. Berti Link to comment Share on other sites More sharing options...
Danny35d Posted September 24, 2005 Share Posted September 24, 2005 What different it make if IniWrite create the section at the end when you have:Reads a value from a standard format .ini file.IniRead ( "filename", "section", "key", "default" )That will read the key not matter where the section is located.... AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted September 24, 2005 Share Posted September 24, 2005 If you had to absolutely have it in order...you could just get the section names, pull an _ArraySort() and then rewrite the file Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) 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