# $config.open

Opens a config file

Syntax

    $config.open(<filename>[,<flags>])

Description

Opens a config file. If the file already exists , its contents are parsed and available for extracting by the $config.read() function.
<filename> may be an absolute path or a relative path: if a relative path is used, KVIrc will complete it with a local kvirc directory suitable for writing script config files.
If the config file doesn't exist , it is opened as empty config file.
Flags can contain a combination of letters 'r' and 'w'.
If only 'r' is specified , the config file is opened in "read-only" mode: no changes will be written to disk.
If only 'w' is specified , the config file is opened in "write-only" mode: the contents of the file on disk are not readed.
If <flags> are not specified then 'rw' is assumed.
The function returns an identifier for the open config file. This identifier is a mandatory parameter in all the other config.* functions and commands.
The config section is set to the default section name: you can change it by using config.setsection.
After you have finished using the file , don't forget to call config.close! KVIrc tries to not open a config file twice: if the file was already opened then the identifier of the open file is returned.
You can check if a config file is already open by using the $config.id() function.

Examples

    # It is a good idea to store the returned id to a variable :)
    %cfg = $config.open(myscript.kvc)
    %num = $config.read(%cfg,Number,0)
    echo Number of entries is %num
    %num++;
    config.write %cfg Number %num
    config.close %cfg

See also
Config module documentation

Index, Functions

KVIrc 3.2.0 Documentation
Generated by root at Mon Mar 13 07:05:21 2006