Como separar os nomes de um arquivos no listview? Entre um carácter??

Delphi

07/11/2019

Olá amigos bom dia.
Estou com um projeto já algum tempo, mas estou atualizando ele para maiores informações na empresa, o que preciso é: quando importar os arquivos (nomes) da música para o listview, ele separe o artista do título, ou por exemplo em uma coluna ele coloca o que está antes do carácter -, e na outra o título, ele coloca o que está depois do carácter -

por exemplo

Blitz - A Dois passos do paraíso

coluna 1 coluna 2
Blitz A dois passos do paraíso

Agradeceria muito pela ajuda desta função.
Obrigado a todos.
Júnior Pinheiro

Júnior Pinheiro

Curtidas 0

Respostas

Júnior Pinheiro

Júnior Pinheiro

07/11/2019

Problema resolvido.

function artista(pStrValue: string): string;
var
  sArtista : string;
  i: Integer;
begin
  if sArtista = '' then
     begin
       result := copy (pStrValue,1, Length(pStrValue)-4);
       for I := 1 to length(pStrValue) do
         begin
           if ((pStrValue[i] = '-') and
               (pStrValue[i-1] = ' ') and
               (pStrValue[i+1] = ' ')) then
            begin
              if length(pStrValue) > (i+4) then
                 begin
                   result := trim(copy (pStrValue,1,i-1))
                 end;
            end;
         end;
     end;
end;
GOSTEI 0
Júnior Pinheiro

Júnior Pinheiro

07/11/2019

Agradeço pela ajuda.
Resolvido.

Problema resolvido.

function artista(pStrValue: string): string;
var
  sArtista : string;
  i: Integer;
begin
  if sArtista = '' then
     begin
       result := copy (pStrValue,1, Length(pStrValue)-4);
       for I := 1 to length(pStrValue) do
         begin
           if ((pStrValue[i] = '-') and
               (pStrValue[i-1] = ' ') and
               (pStrValue[i+1] = ' ')) then
            begin
              if length(pStrValue) > (i+4) then
                 begin
                   result := trim(copy (pStrValue,1,i-1))
                 end;
            end;
         end;
     end;
end;
GOSTEI 0
POSTAR