[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SELF parameter

Posted on 2004-04-12
6
Medium Priority
?
375 Views
Last Modified: 2010-04-05
Hi all,
I have a simple question.

I have to form A and B.
Form B inherits from Form A

In FORM A-

procedure CallP (formName :TForm); virtual; abstract;
procedure example;
.
.
procedure TFormA.example (tobject example);
begin
   FormB.CallP(SELF);
end;
 
-------------------------------
Form B
procedure CallP (formName :TForm); override

procedure TFormB.CallP (formName :TForm);
begin
  inherited;
 
end;


My question is what does the SELF in this sentence -formB.call(self)- means?
does it means TFormA it self and it passes the parameter (TFormA) to formB.CallP
OR
it passes to as SELF to form B and when Form B calles it it calls as itself (TformB)?

I'm confused about the self statement

Thank you

Ian
0
Comment
Question by:AgeOfWars
[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
6 Comments
 
LVL 7

Expert Comment

by:sftweng
ID: 10805459
Self refers to the object within whose scope the procedure resides. Therefore the call FormB.CallP(SELF) within TFormA.example refers to the object of type TFormA. Within the TFormB context, it refers to the TFormB object.
0
 
LVL 9

Expert Comment

by:Cayce
ID: 10805665
The Self parameter means you're passing a reference to the current class instantation (current object).

That is, the TFormB.CallP method expects a TForm parameter, and you're sending the reference of the current instation of TFormA (which should be FormA).

Self is the reference to the current object.

0
 

Author Comment

by:AgeOfWars
ID: 10805714
Hi Cayce and Sftweng

both of your answers are not the same? maybe it is but i'm still not very sure.

Cayce, what you mean is, when TformB.callP (formName :TForm); is called in formB. It is to said that the sentence will be written as TformB.callP (self);  ? Doesn't this refer to formB it self as what Sftweng was saying??

Correct me if i'm wrong. Thanks
ian
0
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.

 
LVL 9

Accepted Solution

by:
Cayce earned 300 total points
ID: 10805797
Specifically to your program:

procedure TFormA.example (tobject example);
begin
   FormB.CallP(SELF);
end;

I'm pretty sure that Self equals FormA, which would be the current instance of TFormA.

Self is the current instance of the class you're in. In this case you're writing code on the TFormA class. So self is a reference to a TFormA object.

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10811198

   Self, Application are "transparent" variables.

  procedure TFormA.example (....);
  begin
    FormB.CallP(SELF);  // here Self reffers to FormA, because you are in the Scope of FormA
  end;

  In addition, if you have ActiveX form in DLL and compile stand alone - Application is the DLL file, but if you have EXE application the use this form, then Application variable is the EXE file ...
0
 

Author Comment

by:AgeOfWars
ID: 10812291
Thanks Cayce for you answser
0

Featured Post

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!

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 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…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 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