Line 20: Where is "Path" coming from?
Line 12: The "Exit" jumps out of the (nested) procedure, not the function.
So, basically, if you pass an invalid index, your code continues on, and tries to access an invalid Index of List.
It's the reason, why i use (nested) Functions instead of procedures for unexpected cleanup
Aircode
Function IsEmptyDirectoryUnset:Boolean;
begin
I:=0;
J:=0;
List.Free;
Result:=True;
end;
.
.
.
.
//For your Lines 22 to 26
if (Index >= List.Count - 1) or (List[Index] = '') then
If IsEmptyDirectoryUnset Then Exit(False);
Line 43 + 44:
Break followed by Exit??
huh?
With Break you jump out of the Loop.... Exit gets never executed....