Printing Delphi

procedure TfrmSorguRap.ToolButton2Click(Sender: TObject);
var
sFile: TextFile;
i,j :integer;
FilterStr:String;
begin
if Query.IsEmpty then Exit;
try
DBGrid1.DataSource.DataSet.DisableControls;
if SaveDialog1.Execute then
if SaveDialog1.FileName<>'' then
begin
{$I-}
AssignFile(sFile,sd.FileName);
ReWrite(sFile);
Query.First;
for i:=0 to Query.Fields.Count-1 do
Write(sFile,Query.Fields[i].FieldName+#9);
Write(sFile,#13#10);
while not Query.EOF do
begin
for i:=0 to Query.Fields.Count-1 do
begin
FilterStr:= Query.Fields[i].AsString;
While Pos(#9,FilterStr)>0 do
Delete(FilterStr,Pos(#9,FilterStr),1);
While Pos(#10,FilterStr)>0 do
Delete(FilterStr,Pos(#10,FilterStr),1);
For j:=1 to Length(FilterStr) do
if FilterStr[j]=#13 then FilterStr[j]:=' ';
Write(sFile,FilterStr+#9);
end;
Write(sFile,#13#10);
Query.Next;
end;
CloseFile(sFile);
{$I+}
end;
finally
DBGrid1.DataSource.DataSet.EnableControls;
end;
end;
Omer Akkın (17/10/2002)