Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

pointer

Posted on 1998-04-06
1
Medium Priority
?
289 Views
Last Modified: 2010-04-06
DELPHIer,

How can I get the pointer of a function ?
Why I cannot access the data when the pointer is nil ?

Andrew
0
Comment
Question by:andrewyu
[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
1 Comment
 
LVL 1

Accepted Solution

by:
extreme earned 20 total points
ID: 1361313
I presume you want to get the address of a function. Well, to get the address depends on the context where you are working. For example, if you want to assign the address of a function to a variable to call the function later using this var you should write code like this:

var
  FOnClick : TNotifyEvent;
begin
  FOnClick := Form1.Button1Click;

  if assigned (FOnClick)
    then FOnClick (xx);


that code get the address of the button1Click method and assign it to the var FOnClick, later you can use the var to call the function, but always you have to check if the value is diferent of nil using assigned. If you don't do so, trying to do something like:

if FOnClick <> nil
   then xxxx....

Delphi tried to call the function because it's in the left of an expression, when the function is in the right in an assignment statement then delphi get the address. That's why you cannot compare directly with nil the function pointer.

When a pointer is nil, is because the pointer don't points to anything, so you cannot reference the pointer otherwise you will get an access violation.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

722 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