Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Mensagem de Processando


Alberto Mota

Pergunta

Prezados colegas,

Gostaria de colocar um label para orientar o usuário, tipo assim:

...Processando

Porque o código realmente demora alguns segundos.

Já tentei colocar visible = true mas não resolve

Como posso resolver isso?

Desde já, obrigado.

Segue o código, o Delphi é 7.

procedure TFrmSindical.BitBtn18Click(Sender: TObject);

var

f:TextFile;

linha, caminho:String;

mov : integer;

fArq: TextFile;

mTexto: TStringList;

i: integer;

sequencial: integer;

associado, remessa: integer;

valor1, valor2, numero2 : string;

tarifa, multa : Real;

contribuinte : String;

dat, dataenvio :string;

data, data2 :TDate;

Valor : real;

numero : integer;

delegacia : string;

ref, nbaixa : integer;

txt, Items : string;

begin

label5.caption := FileListBox1.items.strings[FileListBox1.itemindex];

edit1.text := label10.caption + '\' + label5.Caption ;

label7.Caption := label10.caption + '\' + label5.Caption;

edit3.text := label10.caption + '\' + label5.Caption;

begin

caminho := edit1.text;

AssignFile(f,caminho);

Reset(f); //abre o arquivo para leitura;

While not eof(f) do begin

Readln(f,linha);

if pos('F',linha) = 73 then

Begin

mov := StrToInt(copy(linha,158,6));

txtmov.Text := IntToStr(mov);

label9.caption := IntToStr(mov);

end;

End;

Closefile(f);

end;

//=================

if txtmov.text = '' then

Begin

showmessage('Selecione o arquivo retorno!!!');

FileListBox1.Visible := true;

exit;

end;

txt := txtmov.text;

label11.Visible := true;

label12.Visible := true;

Caminho := Edit1.Text;

AssignFile(fArq, Caminho);

ReSet(fArq);

mTexto := TStringList.Create;

try

mTexto.LoadFromFile(Caminho);

i := 0;

finally

mTexto.Free;

end;

while not Eof(fArq) do

begin

Readln(farq, linha);

//==============================================

//Pega a primeira linha Fenac

if pos('F',linha) = 73 then

Begin

mov := strtoint(copy(linha,158,6));

dataenvio := copy(linha,144,8);

insert('/',dataenvio,3);

insert('/',dataenvio,6);

data2 := strtodate(dataenvio);

end;

//==============================================

if pos('T',linha) = 14 then

Begin

numero := strtoint(copy(linha,185,6));

numero2 := copy(linha,185,6);

contribuinte := copy(linha,40,5);

tarifa := (strtofloat(copy(linha,199,15))/100);

delegacia := copy(linha,179,1);

sequencial := strtoint(copy(linha,9,5));

nbaixa := strtoint(copy(linha,143,6));

remessa := StrToInt(txt);

if numero = 0 then

Begin

numero2 := 'Sindicato';

contribuinte := copy(linha,40,5);

end else

numero2 := copy(linha,179,12);

contribuinte := '0';

if contribuinte = '0' then

Begin

contribuinte := copy(linha,40,5);

//delegacia := copy(linha,179,1);

end else

contribuinte := '0';

//delegacia := '0';

if nbaixa = Null then

Begin

nbaixa := 0

end else

nbaixa := strtoint(copy(linha,143,6));

//===============================

//Segmento T

SegT.Open;

SegT.ExecSQL;

SegT.Append;

SegT.edit;

SegT.FieldbyName('sequencialA').Value := sequencial;

SegT.FieldbyName('numerodoc').Value := numero2;

SegT.FieldbyName('delegacia').Value := delegacia;

SegT.FieldbyName('tarifa').Value := tarifa;

SegT.FieldbyName('lotebase').Value := mov;

SegT.FieldbyName('CodigoContribuinte').Value := contribuinte;

SegT.FieldbyName('seqbaixa').Value := nbaixa;

SegT.FieldbyName('Remessa').Value := remessa;

SegT.FieldbyName('dt').Value := datetostr(data2);

SegT.Post;

SegT.ExecSQL;

end;

//================================

//Segmento U//====================

if pos('U',linha) = 14 then

Begin

dat := copy(linha,138,8);

insert('/',dat,3);

insert('/',dat,6);

data := strtodate(dat);

valor := (strtofloat(copy(linha,93,15))/100); //liquido

multa := (strtofloat(copy(linha,18,15))/100); //juros

SegU.open;

SegU.ExecSQL;

SegU.Append;

SegU.edit;

SegU.FieldbyName('sequencialU').Value := sequencial;

SegU.FieldbyName('sequencialBase').Value := sequencial - 1;

SegU.FieldbyName('dtpgto').Value := datetostr(data);

SegU.FieldbyName('vr').Value := valor;

SegU.FieldbyName('lote').Value := mov;

SegU.FieldbyName('multa').Value := multa;

SegU.Post;

SegU.ExecSQL;

//=================================

Next;

end;

end;

AdoTable4.Close;

AdoTable4.open;

remessas.close;

remessas.open;

Adotable1.Close;

Adotable1.open;

SomaGeral;

BitBtn7.Click;

end;

Editado por Alberto Mota
Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

voce pode usar um Gauge ou um ProgressBar para indicar ao usuario que o processamento esta ocorrendo e que posição esta esse processamento

para leitura do aquivo texto ou outro voce pode pegar o valor maximo de linhas do arquivo usando esse exemplo

var
  aList : TStringList; max, lin : integer;
begin
  aList := TStringList.Create;
  try
    aList.LoadFromFile('C:\arquivo.txt');
    showmessage('Numero de linhas do arquivo: ' + IntToStr(aList.Count));
    max := aList.Count;
  finally
    aList.Free;
  end;
end;
então no seu código voce coloca
gauge1.MaxValue := max;

AssignFile(f,caminho);
Reset(f); //abre o arquivo para leitura;
While not eof(f) do begin

inc(lin);

Readln(f,linha);

gauge1.Progress := lin;

if pos('F',linha) = 73 then
Begin
mov := StrToInt(copy(linha,158,6));
txtmov.Text := IntToStr(mov);
label9.caption := IntToStr(mov);
end;
End;
Closefile(f);

gauge1.Progress := 0;

Faça as adaptações necessarias para seu uso...

para o resto do código, basta usar a mesma lógica

abraço

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...