# 3.7.5.23 Ini

LabTalk Object Type:

Utility

The ini object allows you to access any files that are formatted as INI files which include sections enclosed in square brackets and key names assigned to values.

## Properties:

Property Access Description
ini.file$Read/write string A string with the file name to be accessed by the ini object. The Origin directory is assumed if no path is specified. ini.get.fileName$ N/A

Use ini.file$. This property is provided for backward compatibility only. ini.get.key$ N/A

This property is no longer in use.

ini.get.section$N/A This property is no longer in use. ini.key$ Read/write
string

A string with the key name to be accessed by the ini object.

ini.keyNamekeyNumber$Read string Returns the name of keyNumber for section ini.getSection(sectionName). Example: %A = ini.keyName1$ //returns name of first key in %A.

numeric
Returns the number of keys for section ini.getSection(sectionName).
ini.keyValuekeyNumber$Read string Returns the value of keyNumber for section ini.getSection(sectionName). Example: %A = ini.keyValue1$ //returns value of first key in %A.

ini.section$Read/write, string A string with the section name to be accessed by the ini object. ini.sectionName.keyName Read/write, string Read or write a value in a file. KeyNames are created if they do not exist. ## Methods: Method Description ini.check(SectionName, KeyName) Returns 0 if the sectionName or keyName exists, otherwise returns 1 and creates the sectionName and/or keyName. The keyName is set to 0 when created. ini.get(OGIFilename) Link the contents of an OGI file to Origin objects. The destination objects are determined by the OGI section names. If a section name is prefixed with an "_@", then the name following the prefix identifies a destination object. The section's entry names determine the properties to link. All entries are linked. There is no linking prefix for property names. Section names that are not prefixed with an "_@" are skipped. ini.getSection(SectionName) Returns the number of keys in SectionName. ini.getStr(strvar, default, key, section, file) This method accesses the INI file, section, and key specified in the properties. These can be used for accessing section and key names with spaces or other characters not allowed in LabTalk object/property names. strvar = variable to receive string default = string to return if key not found or blank key = key name. If blank use the value of the Ini.Key$ property.

section = section name. If blank use the value of the Ini.Section$property. file = file name. If blank use the value of the Ini.File$ property.

ini.setStr(value, key, section, file)

This method accesses the INI file, section, and key specified in the properties. These can be used for accessing section and key names with spaces or other characters not allowed in LabTalk object/property names.

value = value to assign to key.

key = key name. If blank use the value of the Ini.Key$property. section = section name. If blank use the value of the Ini.Section$ property.

file = file name. If blank use the value of the Ini.File\$ property.

## Examples:

ini.getStr(A,, Title1, Config, Origin.ini);
%A=;