UDF to enumerate huge ini files.
Note, your will want to use native ReadProfileString() to read the entries in individual sections (unless they are also huge) as the process gets slower towards the end of the file.
Code:
Break ON
$=SetOption("Explicit","ON")
Dim $sIni,$sSections,$sEntries,$sSection,$sEntry
$sIni=".\hugeini.ini"
$sSections=udfEnumHugeIni($sIni)
If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf
For Each $sSection In Split($sSections,Chr(10))
"SECTION: "+$sSection+@CRLF
$sEntries=udfEnumHugeIni($sINI,$sSection)
If @ERROR "["+@ERROR+"] "+@SERROR+@CRLF EndIf
For Each $sEntry in Split($sEntries,Chr(10))
" ENTRY: "+$sEntry+@CRLF
Next
Next
Exit 0
Function udfEnumHugeIni($sPath,Optional $sSection)
Dim $fhIni,$sLine,$iSectionFlag,$sKey,$iExitFlag
$udfEnumHugeIni=""
$iExitFlag=0
$fhIni=FreeFileHandle()
If @ERROR Exit @ERROR EndIF
If Open($fhIni,$sPath) Exit @ERROR EndIf
$sLine=ReadLine($fhIni)
While Not @ERROR AND $iExitFlag=0
$sLine=Trim($sLine)
$sKey=""
If $sLine<>""
If Left($sLine,1)="["
If $iSectionFlag
$iExitFlag=1
Else
$iSectionFlag=0
If $sSection="" $sKey=SubStr($sLine,2,InStr($sline+"]","]")-2) EndIf
If $sLine="["+$sSection+"]" $iSectionFlag=1 $sSection=" " EndIf
EndIf
Else
If $iSectionFlag AND Left($sLine,1)<>";" $sKey=Left($sLine,InStr($sLine+"=","=")-1) EndIf
EndIf
EndIf
If $sKey<>"" $udfEnumHugeIni=$udfEnumHugeIni+$sKey+Chr(10) EndIf
$sLine=ReadLine($fhIni)
Loop
$iExitFlag=Close($fhINI)
Exit 0
EndFunction