The INIFile plugin provides functions to read and write INI (initialization) files. INI files are simply 8-bit ASCII text files divided into sections, each section containing zero or more keys. For example:
There are a number of different flavors of INI files, you might even be familiar with some of them. Here are the formatting rules for INI files that will be used with the INIFile plugin. The only time you might need to be aware of these rules is if you plan to edit an INI file manually.
- Section names must be enclosed in square brackets, and must be the only text on the line.
- Section and key names are case-insensitive, and may contain spaces.
- Leading and trailing spaces in section and key names are not significant and will be ignored.
- A key name must be followed by an equal sign. Spaces before and after the equal sign are ignored.
- If the same section appears more than once in the same file, only the first occurrence is recognized.
- If the same key appears more than once in the same section, only the first occurrence is recognized.
- Blank lines anywhere in an INI file are not significant and can be ignored.
As in normal text files, lines are terminated by a CR (ASCII 13) character or a LF (ASCII 10) character (or a CRLF pair). This means that you can't store these values in an INI file without taking special measures, like encoding CR and LF before storing them.
With all of these restrictions, why would you want to store data in an INI file instead of a plain text file?
The INI file format provides structure to your data which makes storage and retrieval fast and convenient. When using an INI file, you don't have to parse the entire contents of the file to retrieve the data you want, the plugin handles all the details. You can read or write any data, at any point in the INI file, in any order you like. This is effectively a "poor man's database" that has almost no overhead.