Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A Private Global Variable
Message
From
17/06/2002 16:00:23
Irv Adams
MSC Managed Care, Inc.
Florida, United States
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00669192
Message ID:
00669431
Views:
13
I have gotten into the habit (which I prefer) of declaring only one PUBLIC variable, which is a place-holder for my Global App Object (usualy a Custom object although Container works well also). Any other Globally-scoped variables needed are created either at the beginning of the program or later (with .Addproperty) and attached to oGlobal as in:
PUBLIC oGlobal
Set Classlib to <ClassLibLocation>
oGlobal = CreateObject("GlobalApp")
oGlobal.Addproperty("UserColorSet,"")  && early in program...
...
...
oGlobal.UserColorset=RGB(0,0,255)   && somewhere later in program
This way, all variables can be well-documented and they automaticallu go Bye-bye when the global App does...

My 2 cents and more...



>This text was already posted some days ago under 'Coding, Syntax & Commands', but it didn't get much attention over there. I'll try it here once more.
>***********************************************
>
>Hi to all,
>
>After having had a nice conversation with JimB (Re: Public variables Thread #667392 Message #668939) I'd like to propose to the community to use g as scope indicator for variables that are declared public OR PRIVATE in the MAIN program. The g then indicates that it are GLOBAL variables. Global (g) is then simply an indicator that they're visible to the entire application. Here's an example of a main program.
>
>*	Declare GLOBAL variables. Notice that I use the g here for PRIVATE variables.
>*	The g indicates that these variables are visible/global to the entire application.
>*	The only place where private variables are allowed to start with a g is in the main program.
>*	This usage of g is different from what's proposed in the vfp-documentation (where it's
>*	advised for public variables).
>private goMainWindow, goNewActivity, goReports, goOptions
>
>*	References to forms.
>store null to goMainWindow, goNewActivity, goReports, goOptions
>
>do form MainWindow name goMainWindow
>
>read events
>
>release all like g*
>*	The ALL LIKE wouldn't work for public variables.
>*	However, it's not even a necessary statement, for these variables
>*	will go out of scope anyway on return.
>
>RETURN
>
>Feedback please.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform