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.
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).
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).
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().
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.