# $config.open

Opens a config file

Syntax

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

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.
If the optional parameter [r] is specified , the config file is opened in "read-only" mode: no changes will be written to disk.
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!

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

Main index, Function index

KVirc 3.0.0 documentation
Generated by root at Thu Apr 29 12:41:05 2004