Home > Language Reference > File Functions > ReadIni$

ReadIni$

The ReadIni$ function reads a value from an entry in the specified INI file.

Usage

An INI file is easy to manage when external data have to be shared by other scripts. ReadIni$ function accesses directly the desired data without dealing with read pointers, End Of File character, record separator character, etc.

Syntax

var$=Readini$(<filename>,<section>,<item>,<default_value>)

Parameters

<filename>, string, name of ini file to read. If the path is not specified, the file is searched in the Windows folder.

<section>, string, section to read.

<item>, string, item to read.

<default_value>, string. The return value is <default_value> if <filename> or <section> or <item> do not exist.

Return value

var$,  string. It contains the Read result. The result contains <default_value> if <filename> or <section> or <item> do not exist

See also

WriteIni

Examples

If SAMPLE.INI (in c:\wttest) contains:
[Section1]
Item1 = 123
Item2 =

var$=ReadIni$("c:\wttest\sample.ini", "Section1","Item1","Default")
Msgbox(var$)  'Display "123"
var$=ReadIni$("c:\wttest\sample.ini", "Section1","Item2","Default")
Msgbox(var$)  'Display an empty string ("")
var$=ReadIni$("c:\wttest\sample.ini", "Section2","Item2","Default")
Msgbox(var$)  'Display "Default" in var$