Technology Programming

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 Ivan Cvetkovic:

uses Math;function ExtractBasePath(const path1, path2 : string) : string; procedure SplitPath(Path: string; sl: TStrings) ; begin sl.Delimiter := PathDelim; sl.StrictDelimiter := True; sl.DelimitedText := Path; end; var sl1, sl2: TStrings; cnt: Integer; begin Result := EmptyStr;sl1 := TStringList.Create; try SplitPath(Path1, sl1) ;sl2 := TStringList.Create; try SplitPath(Path2, sl2) ;for cnt := 0 to Min(sl1.Count, sl2.count) - 1 dobeginif not AnsiSameText(sl1[cnt], sl2[cnt]) then Break; Result := Result + sl1[cnt] + PathDelim; end; finally sl2.Free; end; finally sl1.Free; end; end;

Explore the list of all accepted entries for ExtractBasePath Delphi challenge.
SHARE
RELATED POSTS on "Technology"
WordPress - How to Set up a New Theme to WordPress 3.
WordPress - How to Set up a New Theme to WordPress 3.
Solution of Creative Web Design
Solution of Creative Web Design
The three disciplines of User Experience
The three disciplines of User Experience
Web Design Sheffield Options For Professional Enterprises
Web Design Sheffield Options For Professional Enterprises
Do you have what it takes?
Do you have what it takes?
Segway Cost
Segway Cost
Microsoft Access 2010: What's Coming with Office 2010?
Microsoft Access 2010: What's Coming with Office 2010?
Companies of Web Development in Ireland Provide Designs that Work
Companies of Web Development in Ireland Provide Designs that Work
Penguin Update to Put Red-Flags on Negative SEO
Penguin Update to Put Red-Flags on Negative SEO
Innovative web 2 design templates can make your business famous quickly
Innovative web 2 design templates can make your business famous quickly
Building A Search Engine Friendly Website
Building A Search Engine Friendly Website
Exceptional Advice To Build Up Your Internet Marketing
Exceptional Advice To Build Up Your Internet Marketing
The Benefits of Selecting The Right Hosting Company
The Benefits of Selecting The Right Hosting Company
Is There a Methodology for Making Successful Logos
Is There a Methodology for Making Successful Logos
Benefits of Ruby On Rails Development
Benefits of Ruby On Rails Development
The Power of Colour and Shapes in Your Infant's Life.
The Power of Colour and Shapes in Your Infant's Life.
Advantages of Hiring PSD To HTML Service Providers
Advantages of Hiring PSD To HTML Service Providers
How to Make Responsive Web Design Attractive?
How to Make Responsive Web Design Attractive?
Converting PSD to Responsive HTML
Converting PSD to Responsive HTML
Just a few realy really hints and tips when it comes to website design but look for.
Just a few realy really hints and tips when it comes to website design but look for.

Leave Your Reply

*