Einzelnen Beitrag anzeigen

Wishmaster

Registriert seit: 14. Sep 2002
Ort: Steinbach, MB, Canada
301 Beiträge
 
Delphi XE2 Architect
 
#5

Re: String Formatierung

  Alt 14. Jun 2008, 11:52
Hi

ich habe es zum laufen gekriegt.

Hier ist meine Lösung

Delphi-Quellcode:

function StringToFilename(fFormat, fTag : String): String;
var SL : TStringList;
    i : Integer;
    s : String;
begin
  SL:= TStringList.Create;
  try
    SL.SetText(pchar(StringReplace(fTag, ',', #13, [rfReplaceAll])));

  for I := 1 to Length(fTag) do { TODO : Length bug }
   begin
    if Copy(fFormat, i, 2) = '%1then
     s:= s + SL[pred(StrToInt(copy(fFormat, i + 1, 1)))]; // Artist

    if Copy(fFormat, i, 2) = '%2then
     s:= s + SL[pred(StrToInt(copy(fFormat, i + 1, 1)))]; // Title

    if Copy(fFormat, i, 2) = '%3then
     s:= s + SL[pred(StrToInt(copy(fFormat, i + 1, 1)))]; // Album

    if Copy(fFormat, i, 2) = '%4then
     s:= s + SL[pred(StrToInt(copy(fFormat, i + 1, 1)))]; // Year

    if Copy(fFormat, i, 2) = '%5then
     s:= s + SL[pred(StrToInt(copy(fFormat, i + 1, 1)))]; // Track

    if Copy(fFormat, i, 2) = '%6then
     s:= s + SL[pred(StrToInt(copy(fFormat, i + 1, 1)))]; // Genre

    if Copy(fFormat, i, 2) = '%7then
     s:= s + SL[pred(StrToInt(copy(fFormat, i + 1, 1)))]; // ' - '
   // or s:= s + ' - '
   end;
  finally
    Result:= s;
    SL.Free;
   end
end;


Thx
  Mit Zitat antworten Zitat