Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scoping
Message
De
22/05/2007 13:50:54
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01227514
Message ID:
01227707
Vues:
21
>>>>What level of scoping do I set a variable to in a procedure within a PRG so that it is available throughout the program? Do I have to define them at the program level before any procedures that contain them are called? Hate using PUBLIC if I don't have to.
>>>
>>>If you set the variable private it would be visible down in the calling chain.
>>
>>Actually, that's not correct - as long as a variable isn't LOCAL it will be 'visible' to any called modules.
>>
>>The purpose of PRIVATE is to hide any *previous* instance of the same variable name, beginning at where the PRIVATE is declared and continuing through any called module. A PRIVATE declaration does not cause the creation of any memory variable.
>
>I'm not seeing contradiction to what I said. At least that's what I meant in my reply.

If you do not declare the variable PRIVATE, it will over write any existing variable with the same name up the chain when you change its value. If you declare it PRIVATE, the existing variables further up the chain will be hidden and not affected by your "new" variable's change in value, which will be seen down the chain.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform