Write a message to a log and display a message, part2

Dear Experts,

Yesterday I have ask a question, and I received a very good solution
from rllibby, I thought that was the solution of my problem. But later
on I have discovered another problem.

This is the code that belongs to the checkbox:

  if DebLog.Checked then
  deb := True
  else Deb := False;

This is the procedure that initiates the logging:

procedure Log(str: string);
var
F: TextFile;
begin
AssignFile(F, 'c:\log.txt');
if not FileExists('c:\log.txt') then
Rewrite(F)
else
Append(F);
Writeln(F, DateTimeToStr(Now) + ': ' + str);
CloseFile(F);
end;

And this is the code that writes the line to the logging:

          if deb then
            Log('Bind successful');

* If the user has checked the checkbox I want all messages being written to a log
  and certain messages have to be written to a log but als display a ShowMessage.

* if the user has unchecked the checkbox no messages will be written to a log
   but the messages that displays ShowMessage, have to be displayed.

Greetings,

Peter Kiers

LVL 1
peterkiersAsked:
Who is Participating?
 
Tomas Helgi JohannssonCommented:
  Hi!

This is very simple as you already have a boolean variable that belongs to this CheckBox
You have all the code that matters to accomplish this.
....
if deb then Log('Bind successful');
ShowMessage('Bind successful');
.....

This will log the message to file if deb is true and display the message using
ShowMessage regardless of the value of deb.

Regards,
   Tomas Helgi
0
 
peterkiersAuthor Commented:
Oke thanks...

500p comming your way

Greetings,

Peter Kiers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.