See also edit
- Config File Parser
- Loading and Saving Application Configuration Files
- One more inifile parser
- Matthias Hoffmann - Tcl-Code-Snippets - Misc - Readprof
- TOML — an INI file alternative with a specification.
Description editThis package provides an interface for easy manipulation of INI files.Reference documentation can be found at
- https://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/modules/inifile/ini.html (latest version)
Discussion editWould 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
- MHo, 2009-05-28: How to read unicode-files like *.reg?