XML and INI configuration files structure description for $.cfgfile macro expression
The configuration files are used for saving constants (parameters and initial values) of the application.
Sometimes it is handy
not to enter some constants directly into the PROMOTIC application (i.e. into the
Application.pra file), but to save it into the configuration (text) file that are linked from the PROMOTIC application. This allows to change the application parameters in this file without the need to edit the application itself.
The PROMOTIC configuration files are text files in the
XML format (newer) or
INI (original, older).
Macro expression $.cfgfile is the easiest and basic way, of obtaining the values contained in the configuration file (both
INI and
XML).
The
XML configuration file allows to save the values into arbitrary hierarchical level.
Macro expression $.cfgfile allows access to values in any hierarchical level (contrary to the
INI configuration file, that contains just two levels - section/key).
1. XML (*.xml) configuration files for $.cfgfile
XML text file consists of tags, attributes and values. XML allows to enter structured (hierarchical) entiries of values. The tags are always paired, marking the beginning ant the end of current section. XML file can be displayed in the Web browser (
Chrome,
Firefox,
Edge,
InternetExplorer ...), that also checks the correctness of the syntax.
For alternative (but very general) access to values in
XML files, see
How to read common XML files in the application.
Example:
Example of the config.xml file with the following content:
<?xml version="1.0" encoding="utf-8"?>
<root>
<data>
<ipaddress>192.168.1.2</ipaddress>
<pcname>ctest</pcname>
<webportnumber>81</webportnumber>
</data>
</root>
Example of link to the
webportnumber value in the
<data> tag supposing that the
config.xml file is registered in the "
Manager of configuration files" configurator identified as
config:
2. INI (*.ini) configuration files for $.cfgfile
INI text file consists of sections and keys - see
Files of the INI type.
The alternative access to INI file values can be managed by methods
Pm.IniFileRead and
Pm.IniFileWrite.
Example1:
Example of the config.ini file with the following content:
[data]
ipaddress=192.168.1.2
pcname=ctest
webportnumber=81
Example2:
Example of link to a key value
webportnumber in the
[data] section supposing that the
config.ini file is registered in the "
Manager of configuration files" configurator with
config identifier: