Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Smallest object in VFP 7
Message
De
11/12/2001 18:30:41
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00590364
Message ID:
00593015
Vues:
37
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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform