# The config module

Managing of configuration files

The config module is a powerful interface that manages text configuration files.
The files are arranged in named sections and the data is stored in key=value pairs belonging to each section.
[section1_name]
<key1>=<value1>
<key2>=<value2>
<key3>=<value3>
....
[section2_name]
<key1>=<value1>
....
Keys and values are plain text strings. Eventual newlines in values are encoded using a simple hexadecimal notation.
The config files can be also edited by using any text editor.
The config module works on config files loaded in memory. For this reason, you must first open a config file by the means of $config.open().
Once you open the file , if it exists on disk , its contents are loaded into memory and you can access the data stored in it. If the file wasn't existing, and empty memory config file is created.
The config file is opened in read-write mode by default. You can also choose the "read-only" method: a read-only config file is never flushed to disk (but you can set the values in memory!).
It is not a good idea to keep a config file open forever: a good approach is to keep settings in memory variables and write them all at once when it comes to write settings: you open the config file , write all your values and close the file.
You can obviously keep the config file open for some time but remember that no change is written to the disk until config.flush or config.close is called.
You write entries by using config.write and read them by using $config.read().
You can change the "current" config section by using config.setsection.
Here comes a complete list of commands and functions exported by this module:
$config.open()
$config.read()
$config.section()
$config.hassection()
$config.sectionlist()
$config.keylist()
$config.filelist()
$config.filename()
$config.id()
$config.readonly()
config.close
config.flush
config.clear
config.clearsection
config.setsection
config.write

Index, Modules

KVIrc 3.2.0 Documentation
Generated by root at Thu Mar 9 08:43:54 2006