Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-05

Unit to read/parse configuration file

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alan Mead

One more question: My data analysis program needs to parse a "command file" to set options, identify variables, determine which statistics to compute, etc.

I combed the web looking for a GPL'd or BSD'd unit (or code) that does this. I found one simple unit CFG_DEF, a unit for reading INI files, and numerous (unusable) Turbo Pascal compiled units. The config code in ptop is closer to what I'm looking for.

I'd like a richer set of syntax features than just 'key=value' and if someone else has already invented this wheel, I'd would rather use that syntax. Something like the following:

foo = bar
foo2 = bar1,bar2,bar3
foo3
foo4 -iterations 1 -nostall

Any ideas?

-Alan Mead

=====
A Congressman was once asked about his attitude toward whiskey. "If you mean the demon drink that poisons the mind, pollutes the body, desecrates family life, and inflames sinners, then I'm against it. "

"But if you mean the elixir of Christmas cheer, the shield against winter chill, the taxable potion that puts needed funds into public coffers to comfort little crippled children, then I'm for it."

"This is my position, and I will not compromise."

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

Marco van de Voort
to Alan Mead
Show quoted text 17 lines
One more question: My data analysis program needs to parse a "command file" to set options, identify variables, determine which statistics to compute, etc. I combed the web looking for a GPL'd or BSD'd unit (or code) that does this. I found one simple unit CFG_DEF, a unit for reading INI files, and numerous (unusable) Turbo Pascal compiled units. The config code in ptop is closer to what I'm looking for. I'd like a richer set of syntax features than just 'key=value' and if someone else has already invented this wheel, I'd would rather use that syntax. Something like the following: foo = bar foo2 = bar1,bar2,bar3 foo3 foo4 -iterations 1 -nostall

As one of my first OOP experiments I wrote a set of classes to build more specialised configuration file handling on top of.

However, except the original examples, I never needed it much, because my programming habits changed a bit due to a different job soon after.

See
http://www.stack.nl/~marcov/files/conffile.zip

It's a bit complex, but it comes with examples (and docs even IIRC). Might need a few small changes since it was written for pre-1.0 FPC.

Alan Mead
to Marco van de Voort
--- Marco van de Voort wrote 6 lines
As one of my first OOP experiments I wrote a set of classes to build more specialised configuration file handling on top of. See http://www.stack.nl/~marcov/files/conffile.zip

Cool. Thanks! This looks like the kind of thing I need.

Looking at this reminds me that I also need to read different data formats. I have already written some code to read delimited files. I'd like to support "FORTRAN format" files using FORTRAN format descriptors. Does anyone have such code? I recall seeing some years ago...

-Alan

=====
A Congressman was once asked about his attitude toward whiskey. "If you mean the demon drink that poisons the mind, pollutes the body, desecrates family life, and inflames sinners, then I'm against it. "

"But if you mean the elixir of Christmas cheer, the shield against winter chill, the taxable potion that puts needed funds into public coffers to comfort little crippled children, then I'm for it."

"This is my position, and I will not compromise."

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

Olaf Leidinger
to Alan Mead: One more question: My data analysis program needs to parse a "command file" to set…
Alan Mead wrote 19 lines
One more question: My data analysis program needs to parse a "command file" to set options, identify variables, determine which statistics to compute, etc. I combed the web looking for a GPL'd or BSD'd unit (or code) that does this. I found one simple unit CFG_DEF, a unit for reading INI files, and numerous (unusable) Turbo Pascal compiled units. The config code in ptop is closer to what I'm looking for. I'd like a richer set of syntax features than just 'key=value' and if someone else has already invented this wheel, I'd would rather use that syntax. Something like the following: foo = bar foo2 = bar1,bar2,bar3 foo3 foo4 -iterations 1 -nostall Any ideas?

You could use xml files. I think there is an interface to libxml somewhere around, isn't it?

Olaf Leidinger

Peter Vreman
to Alan Mead: One more question: My data analysis program needs to parse a "command file" to set…
Show quoted text 8 lines
I combed the web looking for a GPL'd or BSD'd unit (or code) that does this. I found one simple unit CFG_DEF, a unit for reading INI files, and numerous (unusable) Turbo Pascal compiled units. The config code in ptop is closer to what I'm looking for. I'd like a richer set of syntax features than just 'key=value' and if someone else has already invented this wheel, I'd would rather use that syntax. Something like the following:

inifiles in the FCL

Peter