Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A basic thought about LOCAL variables
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00309158
Message ID:
00309562
Views:
27
>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).
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform