Récupérer une chaine de mot depuis un point
D6 et Windows 10 64bits
Bonjour à toutes et à tous,
Avec l'utilisation de "FFMPEG", je sauve des indications dans un fichier texte.
Code pour récupérer l'information : //[ffmpeg] Destination: Audio\El Condor Pasa - Paul Simon & Garfunkel.mp3
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
var
UnStringList:TStringList;
begin
//Création du STringList
UnStringList:=TStringList.Create;
try
//Chargement du fichier texte
UnStringList.LoadFromFile(chappli + 'Titre.txt');
Ednom.Text:=UnStringList.strings[UnStringList.Count-2];
finally
//Destruction du StringList
UnStringList.Free;
end; |
J'obtiens bien la ligne complète dans mon Tedit mais j'aimerai obtenir que tout ce qui est à droite de "Audio\" soit "El Condor Pasa - Paul Simon & Garfunkel.mp3".
Ce qui est à droite varie pour chaque fichier .mp3 !
J'ai testé ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
function GetEveryThingAfter(AfterWhat: String; var TextFile: TStringList): String;
var
I: Integer;
Tmp: Integer;
S: String;
begin
S := '';
Tmp := Pos(AfterWhat, TextFile.Text) + Length(AfterWhat);
Result := Copy(S, Tmp, Length(TextFile.Text));
end;
var
Contents: TStringList;
S: String;
begin
Contents := TStringList.Create; // Tu crées ta liste
try
if FileExists(chappli + 'Titre.txt') then // Si ton fichier existe alors ...
Contents.LoadFromFile(chappli + 'Titre.txt'); // Tu ouvres la liste
S := GetEveryThingAfter('[Audio\]', Contents); // Tu isoles tout après
Memo1.Lines.Clear; // On vide avant
Memo1.Lines.Text := S; // Tu obtiens le tout sous forme de chaîne chariot
Ednom.Text := S;
finally
Contents.Free; // Tu libères ta liste
end;
end; |
Je n'obtiens pas le résultat escompté.
Merci d'une aide éventuelle.
@+,
cincap