Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return dodefault()

Status
Not open for further replies.

pcwc66

IS-IT--Management
Dec 14, 2001
163
US
I remember that under some conditions, "return dodefault()" is needed instead of just simply "dodefault()". I hope someone can give me an example. Have not done too much VFP coding for awhile.
 
Hi pcwc,

I've been programming in VFP for 5 years. I know that's not a great long time, but I've not come across that.

You could have the situation where the parent class method returns a value, in which case I would think you would have the syntax MyVar = DODEFAULT()

If your syntax is legal, I think it would only be of use if the parent method returns something.

Hope that helps,

Stewart
 
pcwc66,

Suppose you are writing code in a method, and you want to call DODEFAULT() for the parent method, and that parent method itself returns a value to its caller. It follows that your (child) method must also return that value. By issuing RETURN DEDEFAULT() from the child method, you are ensuing that it will return the same value as its parent.

If the parent doesn't return a value, you can ignore the issue (although it won't do any harm to leave the command in your code).

Hope this makes sense.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Interesting ...

I was not aware of that the dodefault() as actually a valid function which was returning a value. But it makes sense that it would be.

I may never use it but ... who knows.


Don


 
When you would use DoDefault() is execute the event or method of a parent class that has been overridden in a child class, and has the same name.

So if in a child class, I have an event/method called "DoSomething", and from inside that method, I also wanted to execute the "DoSomething" event from my parent class also, then from inside the child class "DoSomething" routine, I would call DoDefault() which would execute the "DoSomething" method from the parent class.

In the case of the questioner, DoSomething is a function which returns a value, and the value that I want to return from the Child Method DoSomething is the value that would be returned from the Parent's DoSomething function.

RETURN DODEFAULT() causes the parent method to be executed which returns it's value to the child method, which in turn immediately returns that value to the calling process.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Actually, because I use my own base classes that do a lot of integrity checking, all of my "real" forms, that have any additional code, in the LOAD() and/or INIT() methods start with:
Code:
IF !DODEFAULT()
   RETURN .F.
ENDIF
That way the form won't instantiate if there was any problem in the basic class(es).

Rick

 
Don,

I was not aware of that the dodefault() as actually a valid function which was returning a value.

Yes, it is just an ordinary VFP function, albeit one that can only be executed in method code. Not only can it return a value, it can also pass parameters. If the parent method receives parameters, the child method can receive those same parameters and pass them up to the parent via DOFAULT().

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Wow ... Just when I thought my head was "full", in went another concept. [BigSmile]

Don


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top