Jump to content
troller

Debug Box to file

Recommended Posts

still dont get it:(

Never worked with includes before.........

This is how it works WriteLn((TimeToStr(Time))+' Text Here');

 

 

EDIT

I found a command "GetReportText"......I can write in it(AddToReport) but when i save it, it is blank......

I use this proc

program New;

var

s: string; x: Integer;

begin

x := RewriteFile('C:\Debug.txt', false);

s := GetReportText;

AddToReport(s);

WriteFileString(x, s);

CloseFile(x);

end.

 

However, the file created doesnt contain anything...Am i using GetReportText in wrong way?

Edited by troller
Link to comment
Share on other sites

This is the method I use. I put information I want to write into the Report string. Then I write it to the debug box with writeln(Report) and write it to the Report File with UpdateReport(Report). If you want to keep adding information to it every time you run your program then just remove the Rewrite file call that is run when the file is detected.

 

Program program_name;

var
Report : String;
Done : Boolean;
count: integer;

const
ReportPath = 'C:\{dir path you are using}\Report.txt';

Procedure InitReportFile;
var file:integer;
begin
 if not FileExists(ReportPath) then
   begin  // Create the Report File if not there
     file := Rewritefile(ReportPath, False)
     closeFile(file);
   end
 else                                              //  Remove this section
   begin // Clear the Report File for New Session. //  if you want to continue
     file := Rewritefile(ReportPath, False);       //  to add to the file each
     closefile(file);                              //  you run your program
   end;
end;

Procedure UpdateReport(str:string);
var file:integer;
begin  //Writes the string sent to it in the Report File with carriage return
 file := Appendfile(ReportPath, False);
 WriteFileString(file, str);
 writeFilestring(file,#13#10); //Starts text on next line (carriage return)
 CloseFile(file);
 writeln(str); // Adds Update to Debug window
end;

begin
 InitReportFile;
 ClearDebug;
 UpdateReport('-----------Begin Session-------------');
 UpdateReport(DateToStr(Date)+' '+TimeToStr(Time));
 UpdateReport('----------- Version   7 -------------');
 count := 0;
 Repeat
   Report := 'Count has reached '+inttostr(count);
   UpdateReport(report)
   count := count + 1;
   if count > 15 then Done := True;
 until Done;
end.

Edited by Oort
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...