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

Posted on 2007-08-01
Last Modified: 2010-05-18
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);
F: TextFile;
AssignFile(F, 'c:\log.txt');
if not FileExists('c:\log.txt') then
Writeln(F, DateTimeToStr(Now) + ': ' + str);

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.


Peter Kiers

Question by:peterkiers
    LVL 24

    Accepted Solution


    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.

       Tomas Helgi
    LVL 1

    Author Comment

    Oke thanks...

    500p comming your way


    Peter Kiers

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now