Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Smallest object in VFP 7
Message
From
11/12/2001 18:30:41
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00590364
Message ID:
00593015
Views:
36
Thanks Jim, you're teaching me a lot here ;-)

>David,
>
>The problem is that the baseclass Custom does not have a datasession. It participates in its parent or conmtainer's data session. What you could do is this;
>
>Create a prg based class that contains your custom class and has methods of the same names that simply passes the call and the return value. I use the form here because it has a data session and it is a container.
>
>
>* MyUtility.prg
>DEFINE CLASS MyUtil AS Form
>
>PROTECTED oCustom
>Visible=.F.
>
>PROCEDURE Init
>This.Datasession = 2
>IF NOT USED("Addresses")
>   USE Addresses ALIAS Addresses AGAIN SHARED
>ENDIF
>oCustom = CreateObject("YourCustomerClass")
>ENDPROC
>
>PROCEDURE Exists(tcParm)
>
>RETURN This.oCustom.Exists(tcParm)
>ENDPROC
>
>* Put other procedures here
>
>ENDDEFINE
>
>
>Now you simply have your startup program create this class as an object;
>
>
>* Startup program
>
>...
>
>SET PROCEDURE TO MyUtil.prg ADDITIVE
>oAddr = CreateObject("MyUtil")
>
>...
>READ EVENTS
>
>
>Now anywhere in your app you can;
>
>
>llExists = oAddr.Exists(lnAddrNum)
>
>
>Your custom code is preserved without being rewritten and it now has a private data session for the table to be opened.
>
>This approach is called the Decorater pattern or a wrapper class.
Previous
Reply
Map
View

Click here to load this message in the networking platform