 |
ActiveDelphi .: O site do programador Delphi! :.
|
| Exibir mensagem anterior :: Exibir próxima mensagem |
| Autor |
Mensagem |
jrman Novato

Registrado: Sexta-Feira, 24 de Fevereiro de 2017 Mensagens: 80
|
Enviada: Ter Mar 26, 2019 4:05 pm Assunto: Obter dados da Lista, inserindo em outra lista |
|
|
Olá pessoal, estou tentando fazer uma implementação aqui, mas estou batendo cabeça...
Essas são duas linhas da minha lista
AFile[0] : RA;Ano;Turma;Nota; ; ; ; ; ; ; ;
AFile[1] : ; ; B ;F;G;H;I;M;P;Q;TOTAL
Preciso criar uma nova lista obtendo dados mesclados dessas duas linhas, ficaria assim
NovaLinha[0] : RA;Ano;Turma;NotaB;NotaF;NotaG;NotaH;NotaI;NotaM;NotaP;NotaQ;NotaTOTAL;
Tentei fazer assim
| Código: | for i := 0 to Afile.Count - 1 do
begin
novalinha.DelimitedText := AFile[i];
end; |
Mas aí eu só pego o que está na linha até o primeiro ';'
O que fazer para conseguir esse resultado ao final do loop
NovaLinha[0] : RA;Ano;Turma;NotaB;NotaF;NotaG;NotaH;NotaI;NotaM;NotaP;NotaQ;NotaTOTAL;
Obrigado
[/quote] |
|
| Voltar ao Topo |
|
 |
imex Moderador

Registrado: Sexta-Feira, 7 de Janeiro de 2011 Mensagens: 11666
|
Enviada: Ter Mar 26, 2019 8:40 pm Assunto: |
|
|
Boa noite,
Não cheguei a testar mas segue um esboço de código que utiliza 2 TStringLists para separar os valores e adicionar em uma nova TStringList:
| Código: | var
AFile: TStringList;
ListaSepA: TStringList;
ListaSepB: TStringList;
ListaNova: TStringList;
i: integer;
begin
// ...
ListaNova := TStringList.Create;
ListaSepA := TStringList.Create;
ListaSepA.Delimiter := ';';
ListaSepA.StrictDelimiter := true;
ListaSepB := TStringList.Create;
ListaSepB.Delimiter := ';';
ListaSepB.StrictDelimiter := true;
try
i := 0;
while i < AFile.Count - 1 do
begin
ListaSepA.DelimitedText := AFile[i];
ListaSepB.DelimitedText := AFile[i + 1];
ListaNova.Add(Format('%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s',
[ListaSepA[0],
ListaSepA[1],
ListaSepA[2],
ListaSepB[0],
ListaSepB[1],
ListaSepB[2],
ListaSepB[3],
ListaSepB[4],
ListaSepB[5],
ListaSepB[6],
ListaSepB[7],
ListaSepB[8]]));
Inc(i, 2);
end;
ListaNova.SaveToFile('C:\Pasta\Arquivo.txt');
finally
ListaSepA.Free;
ListaSepB.Free;
ListaNova.Free;
end; |
Espero que ajude
_________________
Assinatura: https://www.imoveisemexposicao.com.br/imoveis-alugar-guarulhos-residencial-apartamento |
|
| Voltar ao Topo |
|
 |
|
|
Enviar Mensagens Novas: Proibido. Responder Tópicos Proibido Editar Mensagens: Proibido. Excluir Mensagens: Proibido. Votar em Enquetes: Proibido.
|
|