Solved

Detecting Parameter in Function-Call ...

Posted on 2000-03-16
11
147 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 2

Expert Comment

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

Expert Comment

by:TheNeil
ID: 2624551
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
ID: 2624615
if rxeLog = nil then
....

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

what error do you get?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

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

Expert Comment

by:jhook010598
ID: 2625069
if not assigned(rxelog) then
  //donothing
else
  //dosomething
end
0
 
LVL 12

Expert Comment

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

Accepted Solution

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

Expert Comment

by:Stefaan
ID: 2626847
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
ID: 2626873
"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
ID: 2626874
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
ID: 2628008
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

710 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