Code: Select all
|**
By: Preocts
A quick example of how to read an entire KeyName from and ini file to an array
This example actually sets the size of the array according to the number of Value Names
it reads in from the ini file.
Quick Reminder of IniFile Structure:
/ini [FileName] [SectionName] [KeyName] [Value]
[SectionName]
[KeyName]=[Value]
**|
Sub ReadIni(FileName,SectionName)
|Does the key exist?
/if (${Ini[${FileName},${SectionName},-1,NO].Equal[NO]}) {
/echo KeyName not valid
/return
}
/declare nValues int local 1
/declare KeySet string local ${Ini[${FileName},${SectionName}]}
| Sets KeySet. This will be a single string of all the KeyNames in the ini.
| Ex) KeySet = KeyName1|KeyName2||
:CounterLoop
| Using the Arg function, count how many different Values there are.
/if (!${KeySet.Arg[${nValues},|].Length}) {
/varcalc nValues ${nValues}-1
/goto :MakeArray
}
/varcalc nValues ${nValues}+1
/goto :CounterLoop
:MakeArray
/if (!${nValues}) /return
/declare nArray int local
| Declare the array now that we know the size. Can be int or string
/declare MyArray[${nValues}] string outer
| Set back through the ini, this time filling in the array with the values
/for nArray 1 to ${nValues}
/varset MyArray[${nArray}] ${Ini[${FileName},${SectionName},${KeySet.Arg[${nArray},|]},NULL]}
/next nArray
/return

