Advanced Features

This section explains a few of the more advanced, non-standard features.

Compression
Encryption
Group and Item Repeats
Quoting Strings
Escape Characters
Hashing
Subgroups


Compression

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.

top

Encryption

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.

top

Group and Item Repeats

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,

Example Ini 4: The file before it is loaded before Ini++

[group]
1=one
1=single
2=two
[group]
3=three

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.

Groups

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):

Example Ini 5: The file before it is loaded before Ini++

[group]
1=a
2=b
3=c
[group]
4=d

In “Merge” setting, the groups are all treated as the same one. So the example will be loaded as:

Example Ini 6: Example 5 after it is loaded before Ini++ using ‘Merge’ group repeat mode

[group]
1=a
2=b
3=c
4=d

This is probably the most useful mode and is the default despite its behavior being different to the standard Ini object.

Example Ini 7: Example 5 after it is loaded before Ini++ using ‘Merge’ group repeat mode

[group]
1=a
2=b
3=c
[group.1]
4=d

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.

Items

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.

top

Quoting Strings

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.

top

Escape Characters

Suppose you wish to have an item called “1=1”. Then your Ini file would look a bit like this:

[group]
1=1 = value

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:

[group]
1\=1 = value

The following is a list of escape characters supported:

\n New line¹

\t Tab character, which is otherwise removed as white space at the start or end of an item name

\_ Space character, which is otherwise removed as white space at the start or end of an item name

\q Quote character, so values can start and end with quotation marks. \” also works.

\= Valid only in item names

\; Valid only at the start of item names, to prevent the line being a comment

\[ Valid only at the start of item names, to prevent it being interpreted as a group

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.

top

Hashing

“Hashing” turns a string into a number in a non-reversible way. This is good for storing passwords. For instance,

1. User selects a password for her log in. It is stored using the “Set String (MD5 Hashed)” action. This means the password is never stored, only a number representing it is, and the password cannot be worked out from that.

2. Another day, the user wants to log on again. She writes her password in again and the password is compared to the old one using the “Item Has Hashed Value” condition.

3. If they match she is allowed to log in. Otherwise, the password is wrong and the log on has failed.

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.

top

Subgroups

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.

Example Ini 8: An example of subgroups

[parent]
item = 0
[a]
item = 1
[aa]
item = 2
[ab]
item = 2
[aba]
item = 3
[abb]
item = 3
[abba]
item = 4

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.

Example Ini 9: Example 8 when loaded without the Load and Save Subgroups option

[parent]
item = 0
[a]
item = 1
[aa]
item = 2
[ab]
item = 2
[aba]
item = 3
[abb]
item = 3
[abba]
item = 4

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:

Example Ini 10: Example 8 when loaded with the Load and Save Subgroups option

[parent]
item=0
[parent/a]
item=1
[parent/a/aa]
item=2
[parent/a/ab]
item=2
[parent/a/ab/aba]
item=3
[parent/a/ab/abb]
item=3
[parent/a/ab/abb/abba]
item=4

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!

top