This package provides an interface for easy manipulation of INI files.
Reference documentation can be found at
Please report problems through Tcllib Tickets . Indicate inifile as the affected subsystem.
The package is included in Tcllib since release 1.6.
Would be interesting to have an equivalent for Java properties files (which are like ini files but without sections). The inifile package requires you to have sections to work.
AK: See Tcllib Contribution & Feedback for ways to submit such a feature request.
AF: gee guys thanks for submitting bug reports or rfes. bashing it on here is totally usless. either contribute to the project or go through the proper channels so that these things can be addressed.
MHo: IMO this package has some serious disadvantages:
- A different open mode has to be specified, depending on whether the inifile already exists or not. Why does the package not look by itself if the file exists and choose the appropriate open mode automatically? AF: just like open
- Accidentely specifying w+ as open mode empties the INI file without a word of warning.... AF: just like open
- Writing a comment for a nonexisting key in a nonexisting section does not lead to an error, but after commit nothing is written back. AF: updated in docs
- According to documentation, the sections are written in an arbitrary order and the keys in alphabetical order; this is very bad as INI files are frequently edited by hand too (this is one of the great advantages of inifiles over other methods: they are human-readable. But it's not funny if programmed access to well-commented and hand-designed INIs destroys the layout...). IMO it's absolutely neccessary to keep the existing order in INIs.
- Names are treated case-sensitively whereas under Microsoft Windows this is almost always not common.
- Reading a nonexistent key leads to an error. This requires extra logic (use of ::ini::exists) and/or catching. It would be better if one could provide a default-value instead. AF: added in v0.2
- The INI seems to be locked even if only opened for reading... AF this is an OS limitation, nothing specifically written into the module
- Couldn't get section comments to be created... AF: docs updated to be more clear on this
- INI files could not be READONLY, even though only opened for reading AF: they are definitely opened read only if specified and commit is disabled
There are other packages handling INI-access (don't remember if they are referenced somewhere in this wiki). Perhaps - for the Microsoft Windows platform - it would be a better alternative to use native Win32-APIs (through Ffidl) or the inifile [1 ] module of TWAPI...
AK: Please see the paragraph above about Tcllib Contribution & Feedback. Pretty please file bug reports and enhancement requests in the proper places.
Mho: Ok, but what I mentioned aren't' really bugs; I just wanted to note some quick thoughts about the design philosophy of inifile. Meanwhile I studied the Tcllib Contribution & Feedback page...
AK: Problems with the design philosophy can be seen as high-level architectural bugs. Or as traps a user may run into. And traps should be avoided IMHO. In general I am glad that you tried the package and started a discussion.
Fabricio Rocha - 16 Mar 2009 - I have had problems with the inifile library -- "invalid command ini0" -- and because of that I created a very simple, dict-based simple INI-files parser/writer which might be useful for some people.
no one has ever heard of submitting a bug report. how frustrating!
- MHo, 2009-05-28: How to read unicode-files like *.reg?