Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alternative to public variables
Message
From
11/06/2002 16:34:32
 
 
To
11/06/2002 16:07:35
Sammy Derban
Ghana Telecom
Accra, Ghana
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00667071
Message ID:
00667087
Views:
16
Sammy,

>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?
>

You put this information into properties of an application object. If you create this object in your main program it will be visible to everything below it. I think you should really limit the amount of items that are visible across an entire application.

I don't see how #DEFINE can help you here...

>2. Arrays deinitions - to prevent the erroy message 'array does not exist'
>

I think Hilmar has helped you with this.

>
>PS. May i also know what the real dangers with public variables are?
>

Generally, the lifespan of each variable should be as short as possible. This makes it much easier to debug, and can prevent all sorts of problems. And like Hilmar said, if you have several global variables, you may inadvertantly use that same variable name for another purpose in a function, causing unwanted side effects elsewhere.
Steve Gibson
Previous
Reply
Map
View

Click here to load this message in the networking platform