Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Alternative to public variables
Message
De
11/06/2002 17:12:42
Irv Adams
MSC Managed Care, Inc.
Floride, États-Unis
 
 
À
11/06/2002 16:07:35
Sammy Derban
Ghana Telecom
Accra, Ghana
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00667071
Message ID:
00667105
Vues:
25
Steve and Hilmar are right, and the idea of a Global App variable is really a good solution. I use this extensively.

Create a Custom Global App; add to it all kinds of routines (methods) that you like to use (like one to detect if an instance of your EXE is already running)

First, create the Global App and then instantiate everything from it...
oGlobal = CreateObject("GlobalApp")
oGlobal.AddProperty("MainForm","")
oGlobal.AddProperty("SplashScrn","")
oGlobal.AddProperty("UserName","")

DO FORM TASplashScrn NAME oGlobal.SplashScrn LINKED 
DO FORM TARatesCalc NAME oGlobal.MainForm LINKED 
Now, anywhere within your App you can utilize these 'Global' variables (really properties) via:
oGlobal.UserName = "FRED"
..and when the program Exits, RELEASE oGlobal and all Properties go with it...

HTH,

-Irv.


oGlobal.AddProperty

>Hello All,
>Can someone show me the alternatives using public variable.
>I have used them extensively in my application but i hear it can get really dangerous.
>
>I have used public for the ff;
>
>1. At the main program (startup) to retrieve some table
>values into memory to be used throughout the program without opening the table all the time. I have read about \DEFINE. Can this work for retriving table values?
>
>2. Arrays deinitions - to prevent the erroy message 'array does not exist'
>
>
>PS. May i also know what the real dangers with public variables are?
>
>TIA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform