GARANTIR DESCONTO

Fórum Comparar texto em variavel string #499658

30/10/2014

0

Gostaria de comparar os dados de uma string utilizando a mesma forma do Like do sql. Ex.:

while not Eof(txt) do
begin
ReadLn(txt, line);
if True then
if Trim(line) = LIKE '|0150|' then
end;

Importação do SPED Fiscal, só quero alguns blocos...
Pablo Ricardo

Pablo Ricardo

Responder

Posts

30/10/2014

Pablo Ricardo

   

 ReadLn(txt, line);
    if True then
      if (pos('|C460|', line)) <> 0 then      
        ShowMessage(IntToStr(pos('|C460|', line)));  


Consegui separar assim... más o pos não me parece recomendado pra isso. Poderia substituir pelo que?
Responder

Gostei + 0

30/10/2014

Pablo Ricardo

procedure TfrmImportacaoSPED.LoadArquivo;
var
  txt: TextFile;
  line: String;
  posicao: Integer;
  flag: Boolean;
begin
  flag := False;
  AssignFile(txt, edtPath.Text);
  Reset(txt);
  if fArq = nil then
    fArq := TStringList.Create
  else
    fArq.Clear;
  fArq.BeginUpdate;
  while not Eof(txt) do
  begin
    ReadLn(txt, line);
    if True then
      if (pos('|C460|', line)) <> 0 then
      begin
        fArq.Add(line);
        flag := True;
      end
      else
      begin
        if flag = True then
          fArq.Add(line);
      end;
  end;
  CloseFile(txt);
  fArq.EndUpdate;
  mmo1.Text := fArq.Text;
  FreeAndNil(fArq);
end;


Serviu pro que eu to precisando por hora. Muito obrigado.
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar