TLO:Ini

From the wonderful RedGuides Wiki

Reads value(s) from an ini file located in a relative or absolute path.

This TLO is added by MacroQuest

Forms

Type Member Description
string Ini[filename,section,key,default]
  • The <section>, <key>, and <default> do not need to be given. If <section> or <key> are not given, multiple values are read.
  • Section and key may be set to -1 to skip them and give a new value.
iniadv Ini With no index, it allows access to a newer ini datatype, which is able to handle duplicates and return more information.

Access to Types

Type Description
iniadv A new method to read values from an ini file. Don't call it advanced, call it "robust".
string A string is an array of characters. In MQ there is no single character datatype, so any variable or expression that contains text is considered a string.

Examples

If sample.ini contains:

[SectionOne]
key1=foo
key2=bar
[SectionTwo]
key1=baz
key3=duplicate
key3=foobar

And you type...

/echo ${Ini[sample.ini,SectionOne,key1]}

returns "foo"

/echo ${Ini[sample.ini,SectionOne]}

returns "key1|key2||"

/echo ${Ini[sample.ini]}

returns "SectionOne|SectionTwo||"

/echo ${Ini[sample.ini,SectionTwo,key3]}

returns "duplicate". No way to show foobar.

iniadv examples

Using the same sample.ini above,

/echo ${Ini.File[sample.ini].Section[SectionTwo].Key.ValueAtIndex[2]}

returns "duplicate"

/echo ${Ini.File[sample.ini].Section[SectionTwo].Key[key3].ValueAtIndex[2]}

returns "foobar"

See also