Re: reading configuration files




Hi Bart,

On 18 Feb, 09:48, Bart Vandewoestyne
<MyFirstName.MyLastN...@xxxxxxxxxx> wrote:
Hello all,

In an attempt to make a certain program more flexible in its use,
I would like it to read certain parameters from a textual
configuration file.

For as far as I can see now, the program parameters are all
simple scalar values, so I was wondering what could be the best
format for my configuration file, with respect to readability,
ease of reading in the values in my program and also taking into
account that the people who are entering the values in the
text-files do not know much about Fortran programming.

Some ways of doing it could be for example:

Option 1: use one space
----------------
parameter1 value1
parameter2 value2

Option 2: use :
---------------
parameter1:value1
parameter2:value2

Option 3: use tabs
------------------
parameter1      value1
parameter2      value2

Option 4: use two lines for parameter-value pairs
-------------------------------------------------
parameter1
value1
parameter2
value2

Option 5-...: any other suggestions?
------------------------------------
???

The names 'parameter1' and 'parameter2' do not necessarily have
to be the same length, and also I do not want to make many
assumptions on the input format of the numerical values (say I have
non-fortran users that need to modify the text-files and write
numerical values in it... so they don't know anything about
format descriptors etc...)

What would be a good format for my configuration files so that
i can easily read it in my fortran code and so that it is a bit
robust against different formats for the numerical values.
(e.g. a user could enter 1.0e3 or 1000 or 1000.0.


For input try wherever possible to use list directed ( * ) format.
It deals automagically with almost all the format concerns you
express above. It also makes options 1 and 4 easy to implement.
Personally I don't really like 2, and I strongly suggest you don't
use 3 - that way complete and utter lunacy lies,

Ian
.



Relevant Pages

  • reading configuration files
    ... format for my configuration file, with respect to readability, ... text-files do not know much about Fortran programming. ... assumptions on the input format of the numerical values (say I have ...
    (comp.lang.fortran)
  • Re: reading configuration files
    ... format for my configuration file, with respect to readability, ... text-files do not know much about Fortran programming. ... assumptions on the input format of the numerical values (say I have ... STRING = "a string like this" ...
    (comp.lang.fortran)
  • Re: reading configuration files
    ... format for my configuration file, with respect to readability, ... text-files do not know much about Fortran programming. ... assumptions on the input format of the numerical values (say I have ... The values are read using list directed input, and the text description is simply ignored. ...
    (comp.lang.fortran)
  • Re: Best format for configuration file?
    ... "Jimbo" wrote in message ... > What's the best format to save a configuration file? ... I recommend XML. ... Look for configuration file information in the docs. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Update numbers in database
    ... But i still use the 5,3 input format, because some personell have experience ... "John W. Vinson" wrote: ...
    (microsoft.public.access.queries)