Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Public variables
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00667392
Message ID:
00668831
Views:
33
Peter,

If your application is held up by a READ EVENTS there is no need to declare any variable as PUBLIC. I have seen code wheer the goApp variable is declared public and it does not need to be public. A PRIVATE variable declared prior to the READ EVENTS is visible to every line of code in the application. The ONLY reason to declare a variable PUBLIC is if it needs to be referred to after the declaring program ends and that is of itself a design problem (that the var needs to be referred to after the declaring program ends).

There is only one situation where I declare any var public. That is when I run an application in my debug mode where the reade events is bypassed to allow the command window to reappear and allow access to the debugger and the other utilities of VFP. My startup program is something like this;
LPARAMETERS tlDebug

IF tlDebug
   RELEASE goApp
   PUBLIC goApp
ELSE
   PRIVATE goApp
ENDIF
goApp = CReateObject("TheMainAppMgr")
IF NOT tlDebug
   READ EVENTS
ENDIF
That is the only time the goApp is declared public and it is because I need goApp to survive past the end of the Startup program. When not in debug mode it is not necessary to make the goApp public because the PRIVATE will not go out of scope until the CLEAR EVENTS is executed.

My major point is that in the code I have seen most PUBLIC vars are declared that way even where it is not necessary indicating that the developer does not understand the difference between a PUBLIC var and a global var.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform