Fórum Verificar varios arquivos #130847
22/03/2010
0
var f, arquivo, log:TextFile;
data, NomeDoLog, valor, Maq, Efc, Peso, Linha:String;
i : integer; begin
i := 1;
data := edtData.Text;
while (i <= 20) do begin
AssignFile(f, 'C:\Fiacao\Destino\OE.txt');
NomeDoLog := 'C:\Fiacao\Destino\OE.txt';
AssignFile(log, NomeDoLog);
Reset(f);
While not Eof(f) do
begin
Readln(f, Linha);
if (copy(linha,1,2)='MA') then
maq := (copy(linha,6,2));
if (copy(linha,2,2)='MA') then
efc := (copy(linha,10,6));
if (copy(linha,1,2)='KG') then
peso := (copy(linha,7,7));
end;
closefile(f);
if FileExists(NomeDoLog) then
Append(log)
else
ReWrite(log);
try
WriteLn(log, maq+';'+efc+';'+peso);
finally
CloseFile(log)
end; end;
end;
end.
Carlos
Curtir tópico
+ 0Posts
22/03/2010
Emerson Nascimento
procedure TfrmVicImpFiacao.btnGerarClick(Sender: TObject);
var
f, log: TextFile;
NomeDoLog, Maq, Efc, Peso, Linha: String;
i : integer;
begin
i := 1;
while (i <= 20) do
begin
AssignFile(f, 'C:\Fiacao\Destino\OE.txt'); <- abre uma vez
NomeDoLog := 'C:\Fiacao\Destino\OE.txt';
AssignFile(log, NomeDoLog); <- abre outra vez
Reset(f);
While not Eof(f) do
begin
Readln(f, Linha);
if (copy(linha,1,2)='MA') then
maq := (copy(linha,6,2));
if (copy(linha,2,2)='MA') then
efc := (copy(linha,10,6));
if (copy(linha,1,2)='KG') then
peso := (copy(linha,7,7));
end;
closefile(f);
if FileExists(NomeDoLog) then
Append(log)
else
ReWrite(log);
try
WriteLn(log, maq+';'+efc+';'+peso);
finally
CloseFile(log)
end;
end;
end;
porque abrir duas vezes o mesmo arquivo?
Gostei + 0
22/03/2010
Emerson Nascimento
qual o critério de seleção dos arquivos? todos os arquivos de uma pasta? todos os arquivos iniciados com uma determinada letra? todos os arquivos de uma certa extensão?
Gostei + 0
22/03/2010
Carlos
Gostei + 0
23/03/2010
Marcelo Cavalcanti
sr: TSearchRec; ----------------------------------IMPORTANTE
FileAttrs: Integer;
begin
StringGrid1.RowCount := 1;
if CheckBox1.Checked then
FileAttrs := faReadOnly
else
FileAttrs := 0;
if CheckBox2.Checked then
FileAttrs := FileAttrs + faHidden;
if CheckBox3.Checked then
FileAttrs := FileAttrs + faSysFile;
if CheckBox4.Checked then
FileAttrs := FileAttrs + faVolumeID;
if CheckBox5.Checked then FileAttrs := FileAttrs + faDirectory;
if CheckBox6.Checked then
FileAttrs := FileAttrs + faArchive;
if CheckBox7.Checked then FileAttrs := FileAttrs + faAnyFile; with StringGrid1 do
begin
RowCount := 0; if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then ----------------------------------IMPORTANTE begin
repeat
if (sr.Attr and FileAttrs) = sr.Attr then
begin
RowCount := RowCount + 1;
Cells[1,RowCount-1] := sr.Name;
Cells[2,RowCount-1] := IntToStr(sr.Size);
end;
until FindNext(sr) <> 0; ----------------------------------IMPORTANTE
FindClose(sr); ----------------------------------IMPORTANTE
end;
end;
end; Marcelo Rezende Cavalcanti
--------------------------------------------------------------------
www.swg2.com.br (Transformando suas informações em dados gerenciais)
Gostei + 0
23/03/2010
Marcelo Cavalcanti
--------------------------------------------------------------------
www.swg2.com.br (Transformando suas informações em dados gerenciais)
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)