I'm writing a function that split the PATHEXT environment variable in many substrings.
Since PATHEXT it's a semicolon-separated values string, it uses LastDelimiter(';',pathext_string) to find the split point. But it behaves really weird, and I can't figure out what's wrong in my code. The code fragment is the following... (hope it's clear enough)
procedure my_splitpath(Path: ansistring);
var
rest: ansistring;
Idx: integer;
begin
rest:=Path;
Idx:= LastDelimiter(';', rest);
MMVarValueLarge.Lines.Append(RightStr(rest, Idx));
rest:=LeftStr(rest, Idx -1);
while Idx<>0 do
begin
Idx:= LastDelimiter(';', rest);
MMVarValueLarge.Lines.Append(RightStr(rest, Idx));
rest:=LeftStr(rest, Idx -1);
end;
end;
The output obtained is this:
// .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC starting string!
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;
;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF
;.BAT;.CMD;.VBS;.VBE;.JS;.JSE
E;.BAT;.CMD;.VBS;.VBE;.JS
;.BAT;.CMD;.VBS;.VBE
;.BAT;.CMD;.VBS
;.BAT;.CMD
;.BAT
I tried to swap RightStr() and LeftStr() calls: no effect. Same output.
I can't figure out what's going wrong and why.
Maybe a bug in the FPC string functions? I'm working under win7 x64 professional. Have lazarus 0.9.30.
Or I'm simply, cluelessly, doing some big mistake?

thanks...