Difference between revisions of "Cascading Portable INI files"

From TED Notepad
Line 1: Line 1:
<noinclude>{{manversion|5.3.0.2}}__NOTOC__</noinclude>
+
<noinclude>{{manversion|6.0.0.17}}__NOTOC__</noinclude>
  
TED Notepad is able to store its settings also portably in an INI file, so it can be easilly moved from one computer to another on a USB flash disk or a Floppy disk, carrying its settings along.
+
Besides system Registry, TED Notepad offers to save its {{feature|Config}} into a hierarchy of portable INI files instead. These INI files are quite easily manageable, editable and moveable from one computer to another. They can be stored on USB flash disks, and most importantly, they offer possibility to setup different {{feature|Config}} for each different working directory.
  
The INI file must be placed in the same directory, where the executable file is. It must be named {{system|TedNPad.ini}} (the name is usually {{defined|case insensitive}}).
+
Note: Using INI files prevents using system Registry altogether. One can either use Registry for storing {{feature|Config}}, or benefit from INI files. Also note that unlike INI files, Registry cannot offer per-working-directory {{feature|Config}} storing.
  
When TED Notepad is starting, it searches for that INI file. When successful, it loads its settings from the INI file. Then, upon exit, all settings are always saved back to the INI file, even if it is deleted or modified in the meantime.
+
The INI file must always be named {{system|TedNPad.ini}} in order to be recognized by TED Notepad. The name is usually {{defined|case insensitive}}, but if using Wine under Linux (or other such emulators), make sure the name is {{defined|case sensitive}}.
  
When the {{system|TedNPad.ini}} file is not found, TED Notepad loads its settings from the user registry.
+
The INI file must be encoded in UTF-8 with BOM. This is mandatory. TED Notepad will not bother with verifications and/or conversions, and will simply reject invalid files. Keep this in mind if editing INI files manually.
  
While saving the settings (e.g. upon exit), TED Notepad searches for the {{system|TedNPad.ini}} file again.
+
There are several locations, where {{system|TedNPad.ini}} is being looked for:
If the file is found, it stores the settings into it regardless of whether they were loaded from the registry or from the INI file before. This can be useful to convert your current settings from the registry to the portable INI file.
 
  
Note: There is currently no way to convert the settings from the INI file back to the registry. Once TED Notepad finds the {{system|TedNPad.ini}} file, all settings are stored there in that session.
+
# Directory, where the application executable file is stored, is searched. This is the primary INI file location. If an INI file is found here, {{feature|Config}} is read from it, and loaded values override application default values.
 +
# ''(Only if explicitly requested)'' User profile folder is searched, i.e. the {{system|%UserProfile%}}. This is the secondary INI file location. If an INI file is found here, {{feature|Config}} is read from it, and loaded values override any previously loaded values (e.g. from the primary INI file location) wherever they conflict.
 +
#* Note: User profile folder is not searched by default. This location must be explicitly requested. To request reading INI file from user profile folder, create an INI file in primary INI file location, and in section {{string|[Save]}} add line {{string|<nowiki>IniUPF=1</nowiki>}}. This enables the user profile folder INI file.
 +
# ''(If not explicitly fobidden)'' Current working directory is searched, i.e. the directory from which the application was launched. If launching the application thru Shortcut on Desktop, it is the ''starting directory'' from the Shortcut's properties dialog. This is the tertiary INI file location. If an INI file is found here, {{feature|Config}} is read from it, and loaded values override any previously loaded values (e.g. from the primary or secondary INI file location) wherever they conflict.
 +
#* Note: Current working directory is searched by default. This location can however be explicitly fobidden. To deny reading INI file from current working directory, create an INI file in primary or secondary INI file location, and in section {{string|[Save]}} add line {{string|<nowiki>IniCWD=0</nowiki>}}. This disables the current working directory INI file.
  
Note: Because the INI file must be stored in the same directory, where the executable is, it is not recommended to install TED Notepad with this portable INI file to a {{system|Program files}} folder or as a default notepad replacement, because end users would be probably completely restricted from writing their settings.
+
{{tip}} Since each {{feature|Config}} only carries modified options and settings, this hierarchy of primary, secondary and tertiary INI file locations can be used to create hierarchy of global and local {{feature|Config}} sets. While the primary location affects the entire system, the secondary location affects each user separately, and the tertiary location can be effectively used to share project-specific settings and options.
  
Note: By setting a read-only attribute to the {{system|TedNPad.ini}} file, you will prevent TED Notepad from saving new settings. When you set this attribute on an empty file, you can ensure the default settings forever.
+
Upon {{feature|Config}} saving, all modified options and settings are always written to the last location, where an INI file was found upon {{feature|Config}} loading. Even if such INI file is deleted in the meantime. Note: This ''last known'' location is also indicated on the [[Settings page]] of the {{dialog|Settings}} dialog.
 +
 
 +
Note: If (and only if) no INI file is found in any location, TED Notepad loads {{feature|Config}} from system Registry, particularly user's hive, also known as {{system|HKEY_CURRENT_USER}}. Note: There is no hierarchical loading from system Registry.
 +
 
 +
{{tip}} Setting read-only attribute to the {{system|TedNPad.ini}} prevents TED Notepad from ever saving its {{feature|Config}}. If you set this attribute on an empty file, you can enjoy the default settings forever.
 +
 
 +
{{tip}} Setting hidden attribute to the {{system|TedNPad.ini}} file does not affect {{feature|Config}} loading/saving, but effectively hides the excess file from folders.
 +
 
 +
Administration note: Consider allowing user profile folder INI file location, if installing TED Notepad to {{system|Program Files}} or {{system|SysDir}} folders and creating an INI file there. Also instruct users to create their own INI files in their user profile folders or create them for them. Users might miss privileges to modify system locations, and may thus end up restricted from saving their settings. Although current working directory location may be sufficient in some cases, it can be very frustrating for most users.
 +
 
 +
{{example_start}}{{tip}} Example of INI file enabling secondary and tertiary INI file locations:
 +
{{example_body}}<nowiki>[Save]
 +
IniUPF=1
 +
IniCWD=1</nowiki>
 +
{{example_end}}

Revision as of 21:11, 7 May 2012

This section is up to date for TED Notepad version 6.3.1.0.

Besides system Registry, TED Notepad offers to save its Config into a hierarchy of portable INI files instead. These INI files are quite easily manageable, editable and moveable from one computer to another. They can be stored on USB flash disks, and most importantly, they offer possibility to setup different Config for each different working directory.

Note: Using INI files prevents using system Registry altogether. One can either use Registry for storing Config, or benefit from INI files. Also note that unlike INI files, Registry cannot offer per-working-directory Config storing.

The INI file must always be named TedNPad.ini in order to be recognized by TED Notepad. The name is usually case insensitive, but if using Wine under Linux (or other such emulators), make sure the name is case sensitive.

The INI file must be encoded in UTF-8 with BOM. This is mandatory. TED Notepad will not bother with verifications and/or conversions, and will simply reject invalid files. Keep this in mind if editing INI files manually.

There are several locations, where TedNPad.ini is being looked for:

  1. Directory, where the application executable file is stored, is searched. This is the primary INI file location. If an INI file is found here, Config is read from it, and loaded values override application default values.
  2. (Only if explicitly requested) User profile folder is searched, i.e. the %UserProfile%. This is the secondary INI file location. If an INI file is found here, Config is read from it, and loaded values override any previously loaded values (e.g. from the primary INI file location) wherever they conflict.
    • Note: User profile folder is not searched by default. This location must be explicitly requested. To request reading INI file from user profile folder, create an INI file in primary INI file location, and in section [Save] add line IniUPF=1. This enables the user profile folder INI file.
  3. (If not explicitly fobidden) Current working directory is searched, i.e. the directory from which the application was launched. If launching the application thru Shortcut on Desktop, it is the starting directory from the Shortcut's properties dialog. This is the tertiary INI file location. If an INI file is found here, Config is read from it, and loaded values override any previously loaded values (e.g. from the primary or secondary INI file location) wherever they conflict.
    • Note: Current working directory is searched by default. This location can however be explicitly fobidden. To deny reading INI file from current working directory, create an INI file in primary or secondary INI file location, and in section [Save] add line IniCWD=0. This disables the current working directory INI file.

Tip: Since each Config only carries modified options and settings, this hierarchy of primary, secondary and tertiary INI file locations can be used to create hierarchy of global and local Config sets. While the primary location affects the entire system, the secondary location affects each user separately, and the tertiary location can be effectively used to share project-specific settings and options.

Upon Config saving, all modified options and settings are always written to the last location, where an INI file was found upon Config loading. Even if such INI file is deleted in the meantime. Note: This last known location is also indicated on the Settings page of the Settings dialog.

Note: If (and only if) no INI file is found in any location, TED Notepad loads Config from system Registry, particularly user's hive, also known as HKEY_CURRENT_USER. Note: There is no hierarchical loading from system Registry.

Tip: Setting read-only attribute to the TedNPad.ini prevents TED Notepad from ever saving its Config. If you set this attribute on an empty file, you can enjoy the default settings forever.

Tip: Setting hidden attribute to the TedNPad.ini file does not affect Config loading/saving, but effectively hides the excess file from folders.

Administration note: Consider allowing user profile folder INI file location, if installing TED Notepad to Program Files or SysDir folders and creating an INI file there. Also instruct users to create their own INI files in their user profile folders or create them for them. Users might miss privileges to modify system locations, and may thus end up restricted from saving their settings. Although current working directory location may be sufficient in some cases, it can be very frustrating for most users.

Tip: Example of INI file enabling secondary and tertiary INI file locations:
[Save] IniUPF=1 IniCWD=1