readFromIniFile

Reads parameters from a configuration file (usually *.ini)

Contents

Syntax

ret = readFromIniFile(AppName, KeyName, filename)

Description

ret=readFromIniFile(AppName, KeyName, filename)

This function works like GetPrivateProfileString() from the Windows-API that is well known for reading ini-file data. The parameters are:

AppName = Section name of the type [xxxx] KeyName = Key name separated by an equal to sign, of the type abc = 123 filename = ini file name to be used

ret = string (!) value of the key found, empty ('') if key was not found. Since it's a string, you have to convert to integers / floats on your own.

Note that AppName and KeyName are NOT case sensitive, and that whitespace between '=' and the value will be ignored (removed).

If the key or the AppName is not found, or if the inifile does not exist or could not be opened, '' will be returned (this will also be returned when the key is empty).

Examples:

    %a sample ini file (sample.ini) may have entries:
    %
    %   [XYZ]
    %   abc=123
    %   def=7
    %   ; lines starting with a ; are comments
    %   [ZZZ]
    %   abc=890
 readFromIniFile('XYZ','abc', 'sample.ini') % will return '123'
 readFromIniFile('ZZZ','abc', 'sample.ini') % will return '890'
 readFromIniFile('XYZ','def', 'sample.ini') % will return '7'

Signature