Code a Custom ExtractBasePath Delphi Function

106 4
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:

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...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.