|
本帖最后由 majesty 于 2015-1-22 08:56 编辑
我想在当前文件夹下分别处理几个文件,希望先打开一个文件处理完后关闭,再打开下一个文件继续处理,直到全部文件处理完成。代码编译没有出错,运行就出错,请帮我看一下下面的代码要怎么改改才行。delphi7环境,谢谢
procedure TForm1.Button1Click(Sender: TObject);
var
f: TextFile;
sr: TSearchRec;
stmp: string;
num: Integer;
begin
if FindFirst('*.txt',faAnyfile,sr) = 0 then
begin
repeat
AssignFile(f, '*.txt');
Reset(f);
while not Eof(f) do
begin
Readln(f, stmp);
num := StrToIntDef(stmp, -1);
if num <> -1 then
label1.Caption := FormatFloat('0.00', num/100);
end;
CloseFile(f);
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
|
|