Showing posts with label delphi text file writing. Show all posts
Showing posts with label delphi text file writing. Show all posts

Wednesday, June 6, 2018

Delphi text file writing log (txt) - WriteLog

procedure WriteLog(Msg : string);
var
  f: TextFile;
  ASBName, FileName : String;
begin
  FileName := FormatDateTime('yyyymmdd', Now);
  ASBName  := GetModuleName(HInstance);
  FileName := ExtractFilePath(ASBName)+FileName;
  //ASBName  := ExtractFileName(ASBName);
  FileName := FileName +'_Log.txt';
  Try
    if not DirectoryExists(ExtractFilePath(FileName)) then
       ForceDirectories(ExtractFilePath(FileName));
    AssignFile(f, FileName);
    if FileExists(FileName) then Append(f) else ReWrite(f);
    if Msg = '' then
      Msg := #13+'System DateTime: '+FormatDateTime('dd/mm/yyyy hh:mm:ss:zzz AM/PM', Now);
    Writeln(f, Msg);
    CloseFile(f);
  Except

  End;
end;

Delphi Thread Example

Delphi Thread Example Threads mean a lot with the latest computer technology. They allow you to perform multiple tasks at the same time ...