Ah, herrlich, danke marabu und RavenIV,
hab das jetzt folgendermassen gelöst:
Delphi-Quellcode:
procedure TFCDPS_Observer.LogFileTimerTimer(Sender: TObject);
var
iRow: integer;
LogFileString: string;
fs: TFileStream;
fm: word;
begin
if FileExists(LogFilePfad) then
begin
fm := fmOpenReadWrite;
end
else
begin
fm := fmCreate;
end;
fs := TFileStream.Create(LogFilePfad, fm);
with fs do
begin
Position := Size;
LogFileString := DateTimeToStr(Now) + #13#10;
for iRow := 0 to sg_data_cd.RowCount - 1 do
begin
if sg_data_cd.Cells[0, iRow] <> '' then
begin
LogFileString := LogFileString + sg_data_cd.Rows[iRow].CommaText + ',CD' + #13#10;
end;
end;
LogFileString := LogFileString + #13#10;
for iRow := 0 to sg_data_ld.RowCount - 1 do
begin
if sg_data_ld.Cells[0, iRow] <> '' then
begin
LogFileString := LogFileString + sg_data_ld.Rows[iRow].CommaText + ',LD' + #13#10;
end;
end;
LogFileString := LogFileString + #13#10;
fs.WriteBuffer(LogFileString[1], Length(LogFileString));
fs.Free;
end;
end;