Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Classes - Best Practices?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00763778
Message ID:
00765223
Vues:
20
<snip>
>So I have another question...
>Two things that I really like about VB are constants and enumerations. I like being able to scope my constants as public or local. VFP doesn't provide that exactly, though with #DEFINE...#UNDEFINE you can approximate that behavior. Enumerations appear to be out of the question as well.
>

Enumerations are out of the question. However, I am surprised to hear you say that #DEFINE "can approximate" the behavior. What seems different to you?

>Is there a way in a visual class to use #DEFINE to create a constant that is available to any method in the class?

Include the #DEFINE in an include file, and then include the file using the Class | Include File menu option.

>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.

Well, essentially, that's what a protected property is. In addition, if your classes include single entry points per process (I always code for COM+ components, so that's the case for me), you can define a Private variable in the main entry method, and it will be available in any called methods of the class (as well as called functions and prgs).



>A constant declared in the Init event does not appear to be available to a user-defined method.

Correct.

>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?

Correct.
The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. - Bertrand Russell
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform