Code a Custom ExtractBasePath Delphi Function
Question: Code a Custom ExtractBasePath Delphi Function
Challenge: a custom Delphi function, ExtractBasePath, should take 2 path names (directory or file) and should return the base / common path for the two paths provided.
The code is submitted for the ExtractBasePath Delphi Challenge
Answer:
ExtractBasePath entry by Antonio Bakula:
Explore the list of all accepted entries for ExtractBasePath Delphi challenge.
Challenge: a custom Delphi function, ExtractBasePath, should take 2 path names (directory or file) and should return the base / common path for the two paths provided.
The code is submitted for the ExtractBasePath Delphi Challenge
Answer:
ExtractBasePath entry by Antonio Bakula:
uses Math;function ExtractBasePath(APath1, APath2: string): string; var tempRez: string; xx, minLen: integer; begin minLen := Min(Length(APath1), Length(APath2)) ; Result := ''; tempRez := ''; for xx := 1 to minLen dobegin if APath1[xx] <> APath2[xx] then Break; tempRez := tempRez + APath1[xx]; if APath1[xx] = '\' then Result := tempRez; end; end;
Explore the list of all accepted entries for ExtractBasePath Delphi challenge.
Source...