;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       Ini2Ary() 
;; 
;;ACTION         Enumerates all data of an INI file 
;; 
;;AUTHOR         Glenn Barnas  
;; 
;;VERSION        1.1 - 2005/03/11 
;; 
;;HISTORY        1.0 - 2005/03/04 - Initial Release 
;;               1.1 - 2005/03/11 -  
;; 
;;SYNTAX         Ini2Ary(File) 
;; 
;;PARAMETERS     $File - REQUIRED - String 
;;               - Path/name of INI file to examine 
;; 
;;REMARKS        Populates an array of arrays with the data in a specified INI file.   
;;               Array[0][#] = section name where key/data exists 
;;               Array[1][#] = key name  
;;               Array[2][#] = data value 
;;               Returning three, equal-sized sub-arrays allows a 1:1 relationship  
;;               between the section, key, and data in each element record. This 
;;               permits easy cross-referencing between data, key, and section 
;;               using AScan(). 
;; 
;;RETURNS        Array of arrays 
;; 
;;DEPENDENCIES   EnumIni() 
;; 
;;TESTED WITH    Kix 4.2+, NT4, W2K, WXP, W2K3 
;; 
;;EXAMPLES       Ini2Ary('Ini', 'c:\temp\test.ini') 
;;               $ = AScan($Ini[1], 'Filter') 
;;               'Key "Filter" found in section "' $Ini[0][$] '" and contains "' $Ini[2][$] '"' ? 
; 
Function Ini2Ary($_File)
 
  Dim $_WorkAry[2]
  Dim $_Sects, $_Sect, $_Keys, $_Key, $_Count
 
 
  ; Load the array of arrays 
  ; Determine the number of entries in the INI file 
  $_Count = 0					; init the record count 
  $_Sects = EnumIni($_File)			; get the sections 
 
  If @ERROR
    Exit @ERROR					; Exit on any file error, including empty file 
  EndIf
 
  For Each $_Sect in $_Sects
    $_Keys = EnumIni($_File, $_Sect)		; get the keys 
    $_Count = $_Count + UBound($_Keys) + 1	; count them 
  Next
  $_Count = $_Count - 1				; adjust for element 0 
 
  ; Declare the INI arrays SECTION / KEY / DATA 
  Dim $_aS[$_Count], $_aK[$_Count], $_aD[$_Count]
 
  ; Enumerate the file 
  $_Count = 0
  For Each $_Sect in $_Sects			; parse each section 
    $_Keys = EnumIni($_File, $_Sect)
    If @ERROR <> 0 And @ERROR <> 13
      Exit @ERROR				; exit on hard failures - no keys is OK 
    EndIf
    For Each $_Key in $_Keys			; then the keys in each section 
      $_aS[$_Count] = $_Sect
      $_aK[$_Count] = $_Key
      $_aD[$_Count] = ReadProfileString($_File, $_Sect, $_Key)
      $_Count = $_Count + 1
    Next
  Next
 
  $_WorkAry[0] = $_aS				; Section Name 
  $_WorkAry[1] = $_aK				; Key Name 
  $_WorkAry[2] = $_aD				; Data value 
  $Ini2Ary = $_WorkAry				; return it 
 
EndFunction