Fórum o QUE FALTA POIS TENHO MSG DE FILE NOT FOUND ERROR I/O 32 #186426
06/10/2003
0
procedure TForm1.Button1Click(Sender: TObject);
var
Tfarquivo : TextFile;
StrRegistro : String;
tipo2,tipo : String;
tabela : Ttable;
Arq : TextFile;
NomeDoArquivo : String;
contador : Integer;
begin
with tblitemlojas do zero a tabela antes de começcar a gera-la
begin
active:=false;
databasename :=´lasa´;
tablename:=´Lasadet.DB´;
tabletype:=ttparadox;
emptytable;
active:=true;
end;
// ShellExecute(Handle, ´Open´, ´L:\gera9txt.bat´, ´´, ´´, SW_SHOW )
// funciona dos dois jeitos com Shell ou Winexec
if RgArq.ItemIndex = 0 then
begin
if Rgdepto.ItemIndex = 0 then
ShellExecute(Handle, ´Open´, ´L:\gera9337.bat´, ´´, ´´, SW_hide )
else
if Rgdepto.ItemIndex = 1 then
ShellExecute(Handle, ´Open´, ´L:\gera4337.bat´, ´´, ´´, SW_hide )
else
if Rgdepto.ItemIndex = 2 then
ShellExecute(Handle, ´Open´, ´L:\gera5337.bat´, ´´, ´´, SW_hide )
else
if Rgdepto.ItemIndex = 3 then
ShellExecute(Handle, ´Open´, ´L:\gera337.bat´, ´´, ´´, SW_hide )
else
raise Exception.Create(´Nenhum Departamento foi selecionado´);
end;
A TABELA TBLITEMLOJAS É QUEM ESTA SENDO GERADA
O ARQUIVO .TXT FOI GERADO ATRAVES DO .BAT RODADO LA EM CIMA
tblitemlojas.Open;
tblitemlojas.first;
tblitemlojas.edit;
if Rgdepto.ItemIndex = 0 then
AssignFile (tfarquivo, ´L:\deptopv9.txt´)
else
if Rgdepto.ItemIndex = 1 then
AssignFile (tfarquivo, ´L:\deptopv4.txt´)
else
if Rgdepto.ItemIndex = 2 then
AssignFile (tfarquivo, ´L:\deptopv5.txt´)
else
if Rgdepto.ItemIndex = 3 then
AssignFile (tfarquivo, ´L:\geralpve.txt´)
else
raise Exception.Create(´Nenhum Departamento foi selecionado´);
Reset (tfarquivo); //abre arq. para leitura
contador :=0;
While not eof(tfarquivo) do
begin
Readln(tfarquivo,strRegistro); //lê registros
if copy(strRegistro,1,2) = ´02´ then // somente registro tipo detalhe
begin
if StrToFloat(copy(strRegistro,102,15)) <> 0 then
begin
if StrToFloat(copy(strRegistro,118,15)) <> 0 then //verificar depois pois o estq pode ser 0
begin
tblitemlojas.Insert;
tblitemlojastipopro.value :=copy(strRegistro,3,3);
tblitemlojascdprod.value :=copy(strRegistro,6,13);
tblprodutos.Open;
tblprodutos.First;
while not tblprodutos.Eof do
begin
:oops:
Silvia
Curtir tópico
+ 0Posts
06/10/2003
Lidiane
coloque um codigo mais ou menos assim :
var conta : integer; ///declare esta variavel ///// conta:=0; While not fileexists(´nomedoarquivo.txt´) do begin conta:=conta+1; if conta = 30000 then begin MessageBox(Handle, ´Tempo limite foi alcançado.´, ´Errrrrrro.´, 16); exit; end; end;
Com isso ele vai ler o arquivo se ele existir...
Se prefirir pode usar apenas if not fileexists(´nomedotxt.txt´) then exit;
Espero ter ajudado
Lidiane
Gostei + 0
06/10/2003
Silvia
ele só irá ler o arquivo a´pós ter terminado aexecução do meu .bat, ou não ele faz isso de forma diferente e eu estou pensando que o delphi faz assim e ele faz de outra forma a chamada ao shellexecute ??
Gostei + 0
06/10/2003
Beppe
Ataliba.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)