Separar string com pipe

Delphi

03/11/2014

Eu tenho linha com a seguinte descrição '|0200|4|SALGADOS|||KG|00|19051000||||17|'. Preciso separar os dados do pipe para salvar no banco. Alguma sujestão?

ReadLn(txt, line);
if True then
  if (Pos('|0200|', line)) = 1 then
  begin
    fArq.Add(line);
    //fdquery....
  end;
  if (pos('|0000|', line)) = 1 then
  begin
    //fdquery....
    fArq.Add(line);
  end;
  if (pos('|0005|', line)) = 1 then
  begin
    //fdquery....
    fArq.Add(line);
  end;
  if (pos('|C460|', line)) = 1 then
  begin
    //fdquery....
    fArq.Add(line);
    flagCF := True;
  end
  else
  begin
    if flagCF = True then
      if (pos('|C490|', line)) = 0 then
        //fdquery....
        fArq.Add(line)
      else
        flagCF := False;
  end

Pablo Ricardo

Pablo Ricardo

Curtidas 0

Respostas

Deivison Melo

Deivison Melo

03/11/2014

Dá uma olhada nos links abaixo:

http://www.activedelphi.com.br/forum/viewtopic.php?t=55762&sid=636e5fce2f15cfbe1d13e9cb0816a500

http://williamferreira.net/blog/2011/01/11/delphi-e-split-separacao-de-string-por-delimitador/

https://xucro.wordpress.com/tag/separar-string-por-delimitador/

http://blog.3psolutions.com.br/2009/10/dividir-string-em-delphi.html

http://www.andreanolanusse.com/pt/como-dividir-uma-string-em-um-array-utilizando-delphi/
GOSTEI 0
Pablo Ricardo

Pablo Ricardo

03/11/2014

http://stackoverflow.com/questions/26717672/how-to-separate-strings-with-pipe

Muito obrigado!
GOSTEI 0
POSTAR