I found in a forum item how to get the first section in the INI, which was good, but then I found out the that returned getkey value also included any other section names. This was also true to keys which means you can also get all of the values as well.
The values returned by getkey are separated by chr(0) but also includes chr(0) at the beginning thus the trim commands.
e.g. example.ini
[Section1]
Key1=Key1Value
[Section2]
Key2=Key2Value
Simple but if you didn't know that of the section2 name this would be a problem
I couldn't find an existing topic so just thought I would post it.
Code: Select all
// Enumerate INI Sections/Keys/Values
$GEN_Ini = self("path")."\".self("base").".ini"; // ini file
// $GEN_Ini adjust accordingly to suit needs
$tempstring = "";
$Sections = trim(getkey("", "", $GEN_Ini),chr(0));
foreach($section, $Sections, chr(0))
{
$Keys = trim(getkey("", $section, $GEN_Ini),chr(0));
foreach($key, $Keys, chr(0))
{
$tempstring = $tempstring . "Section : " . $section . "." . $key .
"=>" . getkey($key, $section, $GEN_Ini) .
"<crlf>";
}
}
// output found values for demonstration purposes...
msg $tempstring; // no scrollbar
text $tempstring; // popup box
echo $tempstring;