All pastes #557463 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-11 00:11 UTC
rendered paste body
Module ConfigMod
    Public WebPageExtList() As String
    Public ImageExtList() As String
    Public PlainTextExtList() As String

    Public Function LoadConfig()
        Dim TempLine As String
        Dim CurrentSection As String
        Dim CurrentKey As String
        Dim CurrentValue As String
        Dim I As Integer
        CurrentSection = ""
        Dim FileReadHandle As System.IO.StreamReader
        FileReadHandle = System.IO.File.OpenText(App_Path() & "settings.ini")
        While FileReadHandle.Peek <> -1
            TempLine = FileReadHandle.ReadLine()
            If TempLine Like "[[]*[]]" Then
                CurrentSection = TempLine
            Else
                CurrentKey = Left(TempLine, InStr(TempLine, "=") - 1)
                CurrentValue = Right(TempLine, Len(TempLine) - Len(CurrentKey) - 1)
                Debug.Print(CurrentKey)
                Debug.Print(CurrentValue)
                Select Case CurrentSection
                    Case "[File Extensions]"
                        Select Case CurrentKey
                            Case "WebPageExtensions"
                                WebPageExtList = Split(CurrentValue, Chr(44))
                                For I = 0 To UBound(WebPageExtList)
                                    WebPageExtList(I) = Trim(WebPageExtList(I))
                                Next I
                            Case "ImageExtensions"
                                ImageExtList = Split(CurrentValue, Chr(44))
                                For I = 0 To UBound(ImageExtList)
                                    ImageExtList(I) = Trim(ImageExtList(I))
                                Next I
                            Case "PlainTextExtensions"
                                PlainTextExtList = Split(CurrentValue, Chr(44))
                                For I = 0 To UBound(PlainTextExtList)
                                    PlainTextExtList(I) = Trim(PlainTextExtList(I))
                                Next I
                        End Select
                End Select
            End If
        End While
        FileReadHandle.Close()
    End Function
End Module