Code: Alles auswählen
Procedure.l GetPathPartList(Path$, List.s(), Trennung$ = "")
Protected i.l, lAnz.l, lPos, lPos2.l=1
Path$=Trim(Path$)
ClearList(List())
If Trennung$ <> "\" And Trennung$ <> "/"
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Trennung$ = "\"
CompilerElse
Trennung$ = "/"
CompilerEndIf
EndIf
lAnz = CountString(Path$, Trennung$)
If Trennung$ = "/" : lAnz -1 : lPos2 +1 : EndIf
For i = 1 To lAnz
AddElement(List())
lPos = FindString(Path$, Trennung$, lPos2)
If lPos = 0
lPos = Len(Path$)
EndIf
List()=Mid(Path$,lPos2, lPos - lPos2)
lPos2 = lPos+1
Next
ProcedureReturn lAnz
EndProcedure
NewList List$()
GetPathPartList("C:\Programme\PureBasic.Net\Compiler.exe", List$())
GetPathPartList("/Programme/PureBasic.Net/Compiler.exe", List$(), "/")
CountList(List$())
ForEach List$()
Debug List$()
Next