Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Monad Research
Message
 
To
19/01/2009 12:29:06
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01375100
Message ID:
01375158
Views:
10
* For da loop
public lquit, ndotcolor, nstep
lquit = .F.
nstep = 0

SetupScreen()

* Setup Initial Conditions

public oAbsoluteMatter


oAbsoluteMatter = createobject("collection")

In your posted code there is no reason for the variables being declared to be PUBLIC. I don't know if this has anything to do with your question but it is an issue that is worth mentioning as the PUBLIC declaration only causes those variables to continue to exist beyond the end of the program. If you want your variables explicitly declared for clarity in your code then declare them as PRIVATE.

PUBLIC is NOT synonymous with global. A private variable delcared as such in the highest level program of an application is "global" to that application. Declaring a variable PUBLIC does only one thing and that is to cause the variable to live longer than the program that declares it. A need for PUBLIC variables in an application should always cause one to review their application design as the need for a public variable indicates a really bad design problem related to a lack of encapsulation. To have a situation where a variable needs to be used by code that is not at or below the stack level of the variable's declaration is a serious problem waiting to cause trouble.

Usually, as in the case of your example code, the public declaration is not necessary and is actually a misuse of the public declaration due to not understanding the scoping of variables in VFP.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform