Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Initializing Variable
Message
 
À
29/07/1998 10:00:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00122209
Message ID:
00122318
Vues:
15
>So how long does a PRIVATE variable exist if it remains in existance after a method or procedure has completed. And how is that different from a PUBLIC variable?
>
>Where would you use a PRIVATE variable?
>
>Thanks for your help.

Rixon,

The scope of variables are PUBLIC, PRIVATE, and LOCAL. Variables are PRIVATE by default.
Scope      Created           Destroyed                        Visibility
LOCAL      When declared     When the creating routine ends   The creating
                                                              routine only

PRIVATE    When initialized  When creating routine ends       The creating
                                                              routine and any
                                                              code called from 
                                                              it.

PUBLIC     When declared     When it is released              The creating and 
                                                              all others both
                                                              below it and
                                                              above it in the
                                                              calling stack.
If a variable is created using Var = it will be private unless the var already exists, in that case it will be whatever the existing var is, PRIVATE or PUBLIC (LOCALs from higher routines are hidden from lower routines). A very good practise is to try and use only LOCAL vars as they promote good encapsulation of code and minimize the external coupling of routines.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform