Private Sub GetFileListFromFile(sFile As String)
Dim sContent As String
Dim sExt As String
Dim sMatchStart As Long
Dim sMatchEnd As Long
Dim lContentStart As Long
Open sFile For Input As #1
sContent = Input$(LOF(1), 1)
Do Until Len(sContent) = 0
'looks for file tags
sMatchStart = InStr(1, sContent, "<init_from>")
sMatchEnd = InStr(1, sContent, "</init_from>")
'saves where match was found, to remove later
lContentStart = sMatchEnd + Len("</init_from>")
'if tags were found
If sMatchStart > 0 And sMatchEnd > 0 Then
'get the file path
sMatchStart = sMatchStart + Len("<init_from>")
sFileName = Mid(sContent, sMatchStart, sMatchEnd - sMatchStart)
'determines which slash is used
sMatchStart = InStrRev(sFileName, "/", -1)
sMatchEnd = InStrRev(sFileName, "\", -1)
sMatchStart = IIf(sMatchStart > sMatchEnd, sMatchStart, sMatchEnd)
'slashes found in the path
If sMatchStart > 0 Then
'takes only the file name, starting from the first slash+1
sFileName = Mid(sFileName, sMatchStart + 1, Len(sFileName))
Else
End If
'locates a . char for extension
sMatchStart = InStrRev(sFileName, ".", -1)
'. found, remove extension
If sMatchStart > 0 Then
sFileName = Mid(sFileName, 1, sMatchStart - 1)
'adds .mat
sFileName = sFileName & ".mat"
'adds it to the list
List1.AddItem sFileName
Else
'no point found, file may not have extension, add to list anyways
List1.AddItem sFileName
End If
Else
'no more tags were found
'stops reading file
sContent = ""
End If
'remove from content var all previous content before the match
sContent = Mid(sContent, lContentStart, Len(sContent))
Loop
Close #1
End Sub