Here is snippet of the upi-file. The problems are the duplicate sections which causes the TIniFIle and nearly all other parsers to give up or return only the first section :-/
Main Topics
Browse All TopicsHello,
I've a problem. I have an upi-File (from Symantec UPM) which is as simple ini file but with duplicate section names for use as a batch file. All parser I found doesn't find the section by index - only by name. There is a library which can this: FastIniFiles. But I can't get the source code cos the website is offline. Is there an code I can use to access all section by index or in an array or linked list?
Please help, thx in advance :-)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
This looks like you may have a golden opportunity to learn how to do data parsing. ;-)
In other words, as far as I know, there isn't anything avaialbe that isn't goind to choke on that; however, it shouldn't be too hard to create your own parser that would extract the data. Kindof depends on what you want to do after it is extracted.
It looks like this is a script of some sort for an installation process. In that case, you should be able to parse it and execute the steps as you do so. Although, I would probably build up a batch file from the data so that you could parse it all and check for problems (if you have sufficient information to do that ;-).
@TDS
The reason you are having a problem using the TInifile class is that this file is not a 'well formed' ini file. I've used one of the Windows APIs to enumerate the sections, duplicated as you've already noted, and can only get the contents of the first section with a duplicate name.
You might want to explore regular expression parsing of this file. The actions are located within the square brackets and are followed by one or more lines of name=value pairs.
Of course, you could make a copy of the file, manually eedit it so that the sections are no longer duplicated (for instance, just a a sequencing number in each of the squeare bracketted names), and then work with it.
It kind of depends on what you plan to do with it. If you just need to be able to read it in order to use the data to drive your processing of the file, then I would look at manually editing it. If, on the other hand, you are needing to use it as it was originall intended, then you have a problem.
I think the easiest solution would be the following:
1. read the entire contents into a TStringlist variable
2. iterate through the stringlist items (lines)
3. at each item, check for an equals sign (=) character
if found
parse the item into another stringlist variable using the '=' as the delimiter
else
use the second-through-next-to-las
==========================
If you are trying to mimic the Symantec actions, you need to perform these actions in the order in which they appear. Linked list processing might not preserve that order.
If the name/value lines contain a space character, the method I described above will not work. The DelimitedText always includes spaces in addition to the Delimiter character you assign. bummer :-(
Here is an example of parsing the file and putting the results into a string grid. It correctly parses name/value lines containing a space.
1. I wasn't suggesting you put this in a string grid. I used a string grid on my PC to show me the parsed data on a user form. You only need to pay attention to the acutal line parsing code, not the displaying code.
2. I didn't know your data was unicode. That wasn't in the example you posted.
3. The lastest version of Delphi handles unicode.
Business Accounts
Answer for Membership
by: 8080_DiverPosted on 2009-03-27 at 18:23:52ID: 24006746
Can you provide an example of the file sections? I am not familiar with the particular file definition but I have done extensive INI file parsig and I may be able to help.