Information générale
Catégorie:
Codage, syntaxe et commandes
Jasper,
Here's the difference in PRIVATE & LOCAL variables:
LOCAL:
Local variables and variable arrays can be used and modified only within the procedure or function in which they are created, and cannot be accessed by higher- or lower-level programs. Local variables and arrays are released once the procedure or function containing the local variables and arrays completes execution.
Variables and arrays created with LOCAL are initialized to false (.F.). Any variable or array you wish to declare as local must be declared local prior to assigning it a value. Visual FoxPro generates an error message if you assign a value to a variable or array and later declare it local with LOCAL.
Local variables can be passed by reference.
PRIVATE:
Hides specified variables or arrays that were defined in a calling program from the current program.
The hiding of variables created in higher-level programs enables variables of the same name as the private variables to be manipulated in the current program without affecting the values of the hidden variables. Once the program containing PRIVATE has completed execution, all variables and arrays that were declared private are again available.
PRIVATE doesn't create variables; it simply hides variables declared in higher-level programs from the current program.
Since using VP, I've tended to use LOCAL all the time, as it's easier to manage.
Andy Crawshaw
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement