procedure TForm1.N5Click(Sender: TObject);
var
str:string;
filename:textfile;
i,j,n:integer;
p:string;
begin
if SaveDialog2.Execute then
begin
str:=SaveDialog2.FileName;
assignfile(filename,str);
if fileexists(str) then DeleteFile(SaveDialog1.FileName);
try
Screen.Cursor:=crHourGlass;
rewrite(filename);
p:='|';
str:='';
n:=0;//query字段N序号
Query1.First;
for n:=0 to Query1.FieldCount -1 do
begin
str:=str+Query1.fields[n].DisplayLabel+p;
end;
writeln(filename,str);
n:=0;//query字段N序号
str:='';
while not Query1.Eof do begin
for n:=0 to Query1.FieldCount -1 do
begin
str:=str+Query1.fields[n].AsString+p;
end;
writeln(filename,str);
str:='';
Query1.Next;
end;
except
ShowMessage('写文件时产生错误。可能是该文件已被其他程序打开,或系统错误。');
closefile(filename);
END;
Screen.Cursor:=crdefault;
Application.MessageBox('操作在没有警告的情况下正常结束!','完成',mb_ok+mb_iconinformation);
closefile(filename);
end;
end;