Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variables - Private vs. Local
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Variables - Private vs. Local
Miscellaneous
Thread ID:
00882138
Message ID:
00882138
Views:
52
I'm an experienced dBASE/FoxPro procedural programmer still going through the object oriented learning curve and need some advice. During my DOS days I would break down a large routine into several modules to make maintenance easier. An invoice generation routine might call subroutines to get header, line item, and finishing information. I would simply define my variables in the calling routine and all subroutines automatically could access and change the values of those variables.

Now I see in the Visual FoxPro world that variables can be Global, Private, or Local. My understanding of this is that Global is what used to be known as "public" variables, able to be read and modified by any routines, forms, etc., no matter where they are called. Private corresponds to "standard" variables, like the ones I would declare in a master routine and then access/change with subroutines as needed. I also understand that Local variables are modifiable IN THE LOCAL ROUTINE ONLY and can't be accessed from ANYWHERE ELSE unless explicitly passed along as parameters to a function or form.

Is there a problem with using Private variables accessible from called forms, functions, objects, etc? Yes, I understand that a danger might exist where a Private variable value might be overwritten by a called function or form, maybe written months later. But wouldn't that be the realm of the called function or form developer, who should declare variables LOCAL to that procedure? I don't see much difference whether I have to declare all variables LOCAL and then use parameters like crazy in each single subroutine, or just initialize PRIVATE variables with default values and be careful in coding called forms or functions.

When I scan the messages area I can't help but see that there is a tremendous knowledge resource here with some very gifted developers -- even some authors of books I've bought! Any advice or comments would be appreciated.

- Dean
Next
Reply
Map
View

Click here to load this message in the networking platform