Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding dodefault()
Message
 
 
To
15/12/2018 18:44:03
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
01664512
Message ID:
01664526
Views:
35
>>
>>Now say you have a slightly different situation:
>>BASE_FORM has some code in the LOAD method.
>>You create a child form CHILD_FORM which has no code in the LOAD method.
>>You create a GRAND_CHILD_FORM based on the CHILD_FORM. The GRAND_CHILD_FORM.LOAD has some code. The GRAND_CHILD_FORM.LOAD method does not fire the BASE_FORM.LOAD() code. It fire only if you have DODEFAULT() in the GRAND_CHILD_FORM.LOAD().
>>
>>Why?
>>
>>TIA
>
>
>LOCAL XYZ AS Base_Form
>LOCAL XYZ_2 AS Child_Form
>LOCAL XYZ_3 AS GrandChild_Form
>
>m.XYZ = CREATEOBJECT("Base_Form")
>m.XYZ_2 = CREATEOBJECT("Child_Form")
>m.XYZ_3 = CREATEOBJECT("GrandChild_Form")
>
>DEFINE CLASS Base_Form AS Form
>
>	FUNCTION Load
>		WAIT WINDOW TEXTMERGE("Load, Level 1, <<This.Class>>")
>	ENDFUNC
>
>ENDDEFINE
>
>DEFINE CLASS Child_Form AS Base_Form
>
>ENDDEFINE
>
>DEFINE CLASS GrandChild_Form AS Child_Form
>
>	FUNCTION Load
>		WAIT WINDOW TEXTMERGE("Load, Level 3, <<This.Class>>")
>		DODEFAULT()
>	ENDFUNC
>
>ENDDEFINE
>
>
>Displayed:
>Load, Level 1, Base_form
>Load, Level 1, Child_form
>Load, Level 3, Grandchild_form
>Load, Level 1, Grandchild_form
>
>(that is, the Load in the child class executes the code of its parent class, and the code in Grand-Child inhibits the execution of the code of its parent class, unless reinstated by a DODEFAULT()).

Hi Antonio,
I removed/commented the DODEFAULT() in your example above (which is the case that was I trying to describe in my initial message). That is, in my code I have (for testing purposes) the DODEFAULT(). And in this case I get the following results Displayed:
Load, Level 1, Base_form
Load, Level 1, Child_form
Load, Level 3, Grandchild_form
Which agrees with what Naoto said. That the Grandchild_form Load method should have DODEFAULT() in order to also file the code from the BASE_FORM LOAD method.
This is how I understand it should work and agrees with your example.

What confuses me is that I have a form in my app (CHILD_FORM) and it is based on another form (BASE_FORM) and in the CHILD_FORM load() there is a code but no DODEFAULT() and yet the code from the BASE_FORM Load() fires. I thought that since the CHILD_FORM Load() does not have DODEFAULT(), the code in BASE_FORM Load() should not fire. But it does. I will keep on checking what - I am sure - I am missing.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform