This section explains a few of the more advanced, non-standard features. Compression Encryption Group and Item Repeats Quoting Strings Escape Characters Hashing Subgroups
Huffman compression can be used to compress the Ini file. This works best for large files. Please note that it is possible for the compressed file to be larger than the uncompressed file. This is true for any type of compression. Ini++ cannot automatically detect if an Ini file is compressed or not. The “Use Compression” setting should always be enabled when loading a compressed file for it to be loaded correctly. Similarly, loading an uncompressed file with the “Use Compression” setting selected will not work. If an Ini file is loaded with “Use Compression” off, it can still be later turned on so that subsequent saves are compressed. The same applies the other way around. The “Back-up To...” action allows you to save the Ini as compressed without changing the settings at all. Please note that the data is not compressed in memory. The compression setting does not affect the “Load From String” action or the debugger.
INI files can be encrypted. A key is specified, and the key used to encrypt it must be used to decrypt it. Specifying the wrong key will incorrect decrypt the file. The encryption is not easily broken but it is recommended that sensitive data is not stored in this fashion. The encryption method will never change the size of the file. Encryption is performed before compression (if both are enabled), and so encryption may make compression less effective. Ini++ cannot automatically detect if an Ini file is encrypted or not. The “Encryption” setting should always be enabled and the correct key specified when loading an encrypted file for it to be loaded correctly. Similarly, loading an unencrypted file with the “Encryption” setting selected will not work. If an Ini file is loaded without encryption, it can still be later turned on so that subsequent saves are compressed. The same applies the other way around, and the key can also be changed. The “Back-up To...” action allows you to save the Ini as encrypted without changing the settings at all. Please note that the data is not encrypted in memory. The data can still be extracted using a program that can read the computers memory directly. The key can also be extracted in this manor. It is also possible that the key might be stored as plain text if it was hard-coded in Multimedia Fusion. The encryption setting does not affect the “Load From String” action or the debugger.
In an Ini file it is possible for a group to appear twice. It is also possible for an item to appear twice within the same group. For instance,
Normally in this case the first instance only is read. So only the first instance of the group will be read, and inside the groups only the first instance of every value will be used. Ini++ has extra settings which makes it do something more sensible.
There are four options for what to do if there are multiple groups with the same name: First Takes the first instance only, like the standard Ini object does Last Takes the last instance only Merge Merges the groups together. See below. Rename Renames further groups so they have a unique value. See below. Consider the following example file which has a repeated group (but for simplicity, no repeated items):
In “Merge” setting, the groups are all treated as the same one. So the example will be loaded as:
This is probably the most useful mode and is the default despite its behavior being different to the standard Ini object.
The rename mode renames repeated groups. For instance, the example would be loaded as: As can be seen, subsequent instances of the group are named in the form “Name.n”, where n is a number. The “Perform Search” action can be used to find items in groups of this form.
Repeated items works in a similar way, although “merge” makes no sense in this context. First Takes the first instance only, like the standard Ini object does Last Takes the last instance only Rename Renames subsequent items in the form “Name.n”, where n is a number. The “Find Repeats of Item” action can search for all those in the form easily. If the ‘Save repeated items as original’ option is used then any item in the form ‘item.anything’ will be saved just as ‘item’. This does not effect the data in memory.
Values in Ini files can surrounded by double quotation marks (“””). This is important if the item has leading or trailing white space, as that is ignored. The standard Ini object correctly reads quoted strings but never writes them. This causes leading and trailing spaces to be lost when data is saved using the standard Ini object. Ini++ will always quote strings when they are required to be. With the “Always Quote Strings?” option selected, strings will be quoted even if it is not required. Otherwise, it will not quote the strings if it is not required. With the Standard Ini object, group names are trimmed so that they can never start or end with a space. In Ini++, this is not the case, regardless of mode, and no quotation marks are necessary.
Suppose you wish to have an item called “1=1”. Then your Ini file would look a bit like this:
However, this would be read incorrectly as representing an item with name “1” and value “1 = value”. Usually there is no way around this, but Ini++ adds in escape characters. When escape characters are enabled, “\=” represents an equals sign but without the meaning of it. Therefore, when escape characters are enabled in the items name, we can represent it correctly as:
The following is a list of escape characters supported:
Please note that escape characters are handled automatically. When you use the “Get” expressions, the escape characters are automatically turned back in to what they represent. When you use the “Set” actions, your string automatically get the escape characters added when necessary. Escape characters for groups, items and values can all be set separately.
¹ This represents a new line in the sense of the new line character set in the options, not necessarily a line break.
“Hashing” turns a string into a number in a non-reversible way. This is good for storing passwords. For instance,
If this is done then the Ini file should be encrypted as well. Otherwise, somebody wishing to gain entry to the account could open the Ini file and change the entry to their own value, where they know which string hashes to that value. They have then effectively changed the password. Encryption means they cannot simply change the file to what they want.
Sometimes it is desirable for an Ini group to have subgroups. This is not a standard feature of Ini files, but Ini++ allows it to be easily simulated. In a file, a convenient for a subgroup to be denoted by tabs. For instance, you could imagine a file as follows. Here, ‘parent’ has an item named ‘item’ and has subgroup ‘a’. ‘a’ again has an item named ‘item’ and two subgroups, called ‘aa’ and ‘ab’. This illustrates how subgroups can themselves have subgroups.
Now, ordinarily if you asked Ini++ to load this file, it look as below in example 9. This is because tabs are normally ignored as white space in Ini files. However, these is a special option, Load and Save Subgroups, which will load this file in a more helpful way.
With the Load and Save Subgroups option, every subgroup will be renamed to a path representing it. For instance, the example would be loaded as in example 10 below:
There are then actions like ‘Find Subgroups’ which will list all subgroups of a group. This action has options so you can find the direct subgroups, all subgroups, the first 3 layers of subgroups, those which are exactly ‘great grandson’ groups of the group, or whatever. It is a technique to keep in mind!