udfItemListFromIni
str udfItemListFromIni (str, str, str)
#DefineFunction udfItemListFromIni (strIniFilename, strSection, strDelimiter)
If FileSize (FileLocate (strIniFilename)) == 0 Then Return "" ; Nothing to do.
strSectionsList = strSection
If strSection == "" Then strSectionsList = IniItemizePvt ("", strIniFilename)
intSectionsCount = ItemCount (strSectionsList, @TAB)
strIniList = ""
For intSection = 1 To intSectionsCount
   strSection = ItemExtract (intSection, strSectionsList, @TAB)
   strIniList = ItemInsert (StrCat ("[", strSection, "]"), -1, strIniList, strDelimiter)
   strKeywordsList = IniItemizePvt (strSection, strIniFilename)
   intKeywordsCount = ItemCount (strKeywordsList, @TAB)
   For intKeyword = 1 To intKeywordsCount
      strKeyword = ItemExtract (intKeyword, strKeywordsList, @TAB)
      strValue = IniReadPvt (strSection, strKeyword, "(NONE)", strIniFilename)
      strIniList = ItemInsert (StrCat (strKeyword, "=", strValue), -1, strIniList, strDelimiter)
   Next
   ;strIniList = StrCat (strIniList, strDelimiter) ; Add "empty ruler". This line may be commented out.
Next
Return strIniList
;..........................................................................................................................................
; This UDF udfItemListFromIni converts one section or all sections from an inifile to an itemlist.
;
; strIniFilename ... Filepath to the inifile.
; strSection ....... The name of the section or empty string for all sections to convert from the given inifile.
; strDelimiter ..... Delimiter char to be used for the new itemlist.
;
; From:  rayche raymond.chevalier@vigilance.ca
; Date:  Tuesday, November 26, 2002 01:49 AM
; Conf:  WinBatch
;
; Slightly modified by Detlev Dalitz.20021126.20090502.
;..........................................................................................................................................
#EndFunction


; Test.

:Test1
strIniFilename = "win.ini"

strSection = "windows"
strDelimiter = "|"
strIniList = udfItemListFromIni (strIniFilename, strSection, strDelimiter)
strAskItem = AskItemlist (strIniFilename, strIniList, strDelimiter, @UNSORTED, @SINGLE)

strSection = ""
strDelimiter = @LF
strIniList = udfItemListFromIni (strIniFilename, strSection, strDelimiter)
strAskItem = AskItemlist (strIniFilename, strIniList, strDelimiter, @UNSORTED, @SINGLE)


:Test2
strIniFilename = StrCat (DirHome (), "wil.clr")

strSection = "colors"
strDelimiter = "|"
strIniList = udfItemListFromIni (strIniFilename, strSection, strDelimiter)
strAskItem = AskItemlist (strIniFilename, strIniList, strDelimiter, @UNSORTED, @SINGLE)

strSection = "keywords"
strDelimiter = @LF
strIniList = udfItemListFromIni (strIniFilename, strSection, strDelimiter)
strAskItem = AskItemlist (strIniFilename, strIniList, strDelimiter, @UNSORTED, @SINGLE)

strSection = "whatever"
strDelimiter = @TAB
strIniList = udfItemListFromIni (strIniFilename, strSection, strDelimiter)
strAskItem = AskItemlist (strIniFilename, strIniList, strDelimiter, @UNSORTED, @SINGLE)

:CANCEL
Exit