Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A basic thought about LOCAL variables
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00309158
Message ID:
00309608
Vues:
30
>>No, not entirely. I believe Paul is correct. A PRIVATE variable will not destroy a varible of the same name created at a higher level. An undeclared variable will alter the contents of a variable of the same name created at a higher level. That is what makes an undeclared variable different from an explicitly declared private one.
>
>Fred,
>
>The definition of the scope of a private variable is that it can be changed by a lower level routine. I did not say that assignment will create a private variable because if it alwasy did then there would be no privtae variables. I said, If you create a variable without declaring its scope it will be a private variable. If you assign a value to a variable that exists as a private variable then you are NOT creating a new one. This all goes to the point that you should Always declared your variables. Unless you intend to assign a value to an existing one.
>
>I'm sorry, but Paul is incorrect on this one. Private is private is private and there are no variations on private. Variables created without being delcared are created as private variables. Assigning a value to a variable is not, necessarily, creating the variable. Depending on the assignment of a value to create a variable is a bad practice (but that doesn't change the simple fact that private is the default scope for variables in VFP).

Jim,

I guess we're just splitting hairs here, because I just don't follow everything that you're saying. At least I don't see how it differs from what I said.

We seem to be agreeing on the creation/destruction of variables, but the fact still remains, FoxPro handles the undeclared variable differently based on whether it already exists or not. But yes, an undeclared non-existing variable is the same as declaring a PRIVATE variable. And yes, I agree, that not explicitly declaring variables can cause bad problems, unless that was the intent of the code to use the higher level variable. I would have much prefered the use of EXTERNAL or something like that, to make clear your intentions. That way ALL undeclared variables would be private, and you must specify that you're referencing a variable created elsewhere, IMO.
Fred
Microsoft Visual FoxPro MVP

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

Click here to load this message in the networking platform