Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which class is used if 2 classes have same name in class
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01634985
Message ID:
01635197
Vues:
70
I don't think you can have multiple classes in a single class library, unless the file got corrupted or you mucked around manually with the data file. There's no telling which class it would use - depends on which is found first in a search I'd suspect.

If I recall, in general if you have multiple classes or functions the one declared first is the one that works - the second one is ignored.

But... It's a really good idea to try to avoid that. It can be really tricky to debug this especially if you don't know or forget you have the same function class in multiple places.

+++ Rick ---


>Does anyone know for sure how does VFP behave if somehow a classlib has two classes with the same name inside?
>
>I have some evidence that it ignores the first class in the classlib and uses the last one, but I need to know if that is reliable behavior. There are other cases VFP picks the last of two definitions with the same name. For example, if there are two procedures with the same name in a prg file the second version gets called, not the first one.
>
>The SET CLASSLIB Command help explanation includes the following:
>
>When CREATEOBJECT( ), ADD OBJECT in DEFINE CLASS, or the AddObject method is issued, Visual FoxPro searches for the class definition defining the object specified in these commands in the following locations and order: 
>  1. The Visual FoxPro base classes.
>  2. Class definitions in memory in the order they are loaded.
>  3. Class definitions in the current program.
>  4. Class definitions in the .vcx class libraries opened with SET CLASSLIB.
>  5. Class definitions in procedure files opened with SET PROCEDURE.
>  6. Class definitions in the Visual FoxPro program execution chain.
>  7. The OLE Registry if SET OLEOBJECT is set to ON.
>
>If the class definition containing the object cannot be located, Visual FoxPro generates an error message.
>
>
>TIA,
>
>Alex
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform