Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alternative to public variables
Message
From
11/06/2002 16:19:31
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
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:
00667079
Views:
36
>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?

#DEFINE will only work for real constants. To read a value from a table or text-file, a global variable is really the only choice.

A variable declared in your main program is public for practical reasons (unless you declare it LOCAL), since it is available everywhere.

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

See help for EXTERNAL.

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

The real danger is messy programming. If you have scores of public variables, and then forget one of them, you may overwrite the value somewhere else.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform