Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Classes - Best Practices?
Message
From
12/03/2003 18:17:37
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00763778
Message ID:
00765182
Views:
24
John,

>
>If I put each class in a separate .PRG file I need to use a sequence of SET PROCEDURE TO ... ADDITIVE commands to use them within my apps and they won't show up in the class browser at all - at least not that I've seen.
>

You can use SET PROCEDURE TO, or you can use newobject() to tell it where to find the class definition.
oInstance = newobject("class1","class1.prg")
>However, if I put them all in a VCX file I get the benefit of them showing in the class browser and being able to add them all with one SET CLASSLIB TO... command. While I would prefer having everything in code, it looks like I basically have to fight VFP to do it. So I'm leaning toward the VCX files for ease of use - even though my classes are not visual.
>

I prefer .prg files for non-visual classes, using newobject() to create objects.

>So I have another question...
< snip >
Is there a way in a visual class to use #DEFINE to create a constant that is available to any method in the class? For that matter, can you create a non-public variable that is available to any method in the class? It doesn't appear that it's possible from what I've tried so far. A constant declared in the Init event does not appear to be available to a user-defined method. And variables only seem to be available if created as PUBLICs.
>
>With the .PRG approach, I can create constants at the beginning of a class definition and #UNDEFINE them afterwards and have, in effect, a class level constant. I don't think I can do the same with variables as any variables declared at the class level become properties.
>
>Any thoughts?

What is wrong with using properties of the class? Look at HIDDEN and PROTECTED keywords in DEFINE CLASS command, maybe that will help you get the scope you desire...

My ideas are worth about $.02US. :)
Steve Gibson
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform