#135765 - 2005-03-17 03:04 PM
Re: How do I make the ReadProfileString jump over...
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
I'm a bit late to the party, but...
This script will return all the sections, entries and values as an array that you can enumerate.
It also returns all the bad sections and entries, including malformed sections and entries with no values.
Code:
$=SetOption("Explicit","ON") Dim $sIniFile,$asIniCollection,$asIniItem $sIniFile="\path\to\myinifile.ini" $asIniCollection=EnumIni($sIniFile) For Each $asIniItem in $asIniCollection ? "Section: '" $asIniItem[0] "'" ? "Key : '" $asIniItem[1] "'" ? "Value : '" $asIniItem[2] "'" ? Next Function EnumIni($sIniFile) Dim $fd,$sLine Dim $aEntry[3] $fd=FreeFileHandle() If @ERROR Exit @ERROR EndIf If Open($fd,$sIniFile) Exit @ERROR EndIf $sLine=ReadLine($fd) While Not @ERROR $sLine=LTrim($sLine) If $sLine<>"" AND Left($sLine,1)<>";" $aEntry[1]="" $aEntry[2]="" If Left($sLine,1)="[" $aEntry[0]=SubStr($sLine,2,InStr($sLine+"]","]")-2) Else $aEntry[1]=Left($sLine,InStr($sLine+"=","=")-1) $aEntry[2]=SubStr($sLine,Len($aEntry[1])+2) Redim Preserve $EnumIni[UBound($EnumIni)+1] $EnumIni[UBound($Enumini)]=$aEntry EndIf EndIf $sLine=ReadLine($fd) Loop EndFunction
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1334 anonymous users online.
|
|
|