ReadIni

Description:

baReadIni gets a string from a Windows ini file.

Platforms:

Windows and Macintosh

Usage:

Result = baReadIni( Section, Keyname, Default, IniFile )

Arguments:

String, string, string, string.
Section is the section name of the ini file.
Keyname is the name of the key
Default is the string that is returned if the file, section or key doesn't exist.
IniFile is the name if the ini file to use.

Returns:

String.
Returns the value associated with the Keyname. If the IniFile, Section or Keyname doesn't exist, then the return will be the Default string.

Examples:

Director:
Name = baReadIni( "CurrentUser", "UserName", "Error", "Userdat.ini" )

Authorware:
Name := baReadIni( "CurrentUser", "UserName", "Error", "Userdat.ini" )
 

Notes:

An entry in a ini file has the following format :

[Section]
Keyname=string

This function will return the string after the equals sign. When using this function, the Section name you use should not include the square brackets around the name. The Keyname should not include the equals sign. For example the ini file for the example above might look something like this

[CurrentUser]
UserName=Gary Smith
Password=mypw
ModulesCompleted=4

The IniFile can be in any directory. On Windows, if the full path is not specified the file will be assumed to be in the Windows directory, on the Macintosh it will be assumed to be in the Preferences folder.

The ini file does not have to have an .ini extension: any extension can be used.

This function returns a maximum of 32000 characters.

This function will not read Unicode characters.
 

See also:

baWriteIni
baFlushIni
baDeleteIniEntry
baDeleteIniSection