Solved

Detecting Parameter in Function-Call ...

Posted on 2000-03-16
11
141 Views
Last Modified: 2010-04-04
Hi Experts,

I'm writing a function which has to write a given Message to :
  1) a Rx-RichEdit (given parameter)
and/or
  2) a LogFile on disk (given parameter)

Here's my function definition :
Function  WriteMessage(rxreLog: TRxRichEdit ; Msg: String ; strLogFile: String ;
                       colKleur: TColor) : Boolean;


This is what I want to do :
If the user passes NIL for rxreLog, then the message should not be written to the rxRichEdit.

If the user passes '' for strLogFile, then the message should not be written to the logfile on disk.


Now my question :
How can I detect if the rxreLog-parameter is nil ?
The following statement doesn't work :
  if rxreLog = nil then
    DoNothing
  else
    DoWrite


Can someone please help me out with this ?


Thanx in advance.

The Mayor.
0
Comment
Question by:wimmeyvaert
11 Comments
 
LVL 2

Expert Comment

by:craig_capel
Comment Utility
have you tried... if rxrelog = 0 then
  do nothing?
0
 
LVL 5

Expert Comment

by:TheNeil
Comment Utility
I don't know about rxRichEdit but using standard RichEdit your test will always return FALSE (i.e. rxreLog is NOT nil) unless you specifically set rxreLog to nil (e.g. rxreLog := nil)

You might be better off passing something other than a RichEdit (or variation) OR passing another value holding something like the line count (-1 indicating no lines). No better ideas I'm afraid

The Neil
0
 
LVL 3

Expert Comment

by:markshiffer
Comment Utility
if rxeLog = nil then
....

rxeLog is just a pointer so you can test directly for nil

what error do you get?
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
? what about
if assigned(rxelog) then
  //doall
else
  //donothing
0
 

Expert Comment

by:jhook010598
Comment Utility
if not assigned(rxelog) then
  //donothing
else
  //dosomething
end
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
Can you show us how you are calling the function?
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
Comment Utility
to jhook,
i don't like negative conditions,
therefore i've changed the order in my comment ;-)
0
 
LVL 3

Expert Comment

by:Stefaan
Comment Utility
Yo Mayor,

Zeg manneke da mocht ge altijd aan mij persoonlijk vragen ook zunne ;-)

E-mail : Stefaan.Lesage@dexia.be
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
"if Assigned(object) then" is exactly the same as "if object = nil then". Both should work alright. Where is the problem? It works for me!   :-)

Regards, Madshi.
0
 
LVL 6

Author Comment

by:wimmeyvaert
Comment Utility
Hi,

I want to thank everybody for the fast replies.

My conclusion is that the comment of Kretzschmar is the best solution for me.
So I grant the points to you ;-)


Greetings,
The Mayor

P.S. : Is there a possibility to split the points and give them to 2 experts?
If so, how can you do this?
0
 
LVL 3

Expert Comment

by:Stefaan
Comment Utility
Hi Mayor,

Well there isn't exacly a way to split the points.  Normally we simply post a new question for a specific person, so that he/she can get the points too ;-)

Best regards,


Stefaan

a.k.a. Kingetje

P.S. : I'll call you this or next week
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

7 Experts available now in Live!

Get 1:1 Help Now