Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return .f. still allows exit from field. Why?
Message
From
28/08/1999 22:28:46
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00258304
Message ID:
00258890
Views:
12
>When you subclass something and want to extend the functionality, you need to determine whether it supplements the inherited code or supplants the code. If it supplants (completely replaces), then your code should never execute a DODEFAULT, and in fact, if base class behavior should be filtered, a NODEAULT should be added to the code.
>
>If my code enhances the parent class code, I need to decide if I filter out the conditions under which the parent class acts, or if I want to act after the default behavior. I use the following contructs:
>
>
*Enhance after the basic functionality is used
>LOCAL uReturn
>uReturn = DODEFAULT() && catch parent's return and save
>DO CASE
>CASE <i>something that this handles afterwards</i>
>   *do some stuff
>   uReturn = <i>whatever I want returned</i>
>CASE <i>something else that this handles afterwards</i>
>   *do some stuff
>   uReturn = <i>whatever I want returned</i>
>ENDCASE
>RETURN uReturn
>
>*Filter where the base code executes only when I don't
>LOCAL uReturn
>uReturn = <i>some default in case I get stupid</i>
>*  If I want to block base class behavior, too, add a NODEFAULT
>DO CASE
>CASE <i>something that this handles instead of parent's</i>
>   *do some stuff
>   uReturn = <i>whatever I want returned</i>
>CASE <i>something else that this handles instead of parent's</i>
>   *do some stuff
>   uReturn = <i>whatever I want returned</i>
>OTHERWISE
>   uReturn = DODEFAULT() && catch what would normally come back
>ENDCASE
>RETURN uReturn
You sir, are a natural and gifted teacher! That finally rammed it into my head.

I was indeed adding a further condition and a dodefault in the form intantiation. At first I thought, move it to the lostfocus and let the valid reset to default, but then, following the logic of your extremely helpful example, I figured if I just put the following lines in front of my additional condition it should work:

ureturn=dodefault()
if not ureturn
return .f.
endif
my additional conditions...

and it did!

so now I see how you can selectively add to or replace the base class code (which I must confess I hadn't even considered once I wrote my own validation; naively assuming it would just disappear from the equation.) in the subclass and still add to it in the various instances on the final forms.

(I've also now surrounded the code in the subclass with code running the base class option as a default similar to your example. )

[SET ILLUMINATION=ON]

Thanks

Harry
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform