How to Save a TXT File with a Date in Delphi

How to Save a TXT File with a Date in Delphi

This AfterUpdateRecord event handler keeps a log file of successful record postings, including the username, date, time, and client dataset name.

procedure TMyRDM.Provider1AfterUpdateRecord(Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet; UpdateKind: TUpdateKind);
const
  SP = '  ';
var
  logfile: TextFile;
begin
  AssignFile(logfile,'log.txt');
  if not(FileExists('log.txt')) then ReWrite(logfile)
  else Append(logfile);
  writeln(logfile,(UserName+SP+DateToStr(Date)+SP+TimeToStr(Time)+SP+
        DeltaDS.Name));
end;