• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

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

0
peterkiers
Asked:
peterkiers
1 Solution
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now