Einzelnen Beitrag anzeigen

nuclearping

Registriert seit: 7. Jun 2008
708 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#5

AW: ExtractFilePath aus einem String mit zwei Dateiangaben

  Alt 24. Mär 2014, 20:25
Man kann auch eine TStringList mit DelimitedText und QuoteChar nehmen. Die macht den ganzen Spaß alleine.

http://www.delphibasics.co.uk/RTL.asp?Name=TStringList

3. Beispiel:
Delphi-Quellcode:
var
  cars : TStringList; // Define our string list variable
  i : Integer;
begin
  // Define a string list object, and point our variable at it
  cars := TStringList.Create;

  // Now add some cars to our list - using the DelimitedText property
  // with overriden control variables
  cars.Delimiter := ' '; // Each list item will be blank separated
  cars.QuoteChar := '|'; // And each item will be quoted with |'s
  cars.DelimitedText := '|Honda Jazz| |Ford Mondeo| |Jaguar "E-type"|';

  // Now display these cars
  for i := 0 to cars.Count-1 do
    ShowMessage(cars[i]); // cars[i] equates to cars.Strings[i]

  // Free up the list object
  cars.Free;
end;
Ausgabe:
Code:
   Honda Jazz
   Ford Mondeo
   Jaguar "E-type"
  Mit Zitat antworten Zitat