Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
_vfp.setvar help
Message
From
31/01/2000 12:11:10
 
 
To
31/01/2000 11:49:00
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00325066
Message ID:
00325087
Views:
27
>I am trying learn how to use the _vfp.setvar() method to create variables on the main vfp application object that can be accessed from any form using the _vfp.eval() method.
>
>I am having trouble understanding the scope of the _vfp.setvar() calls...
>

It creates a private in the scope of the calling procedure if it does not already exist.

>If I create the object variable using _vfp.setvar() in my main .prg file (before any forms are called), they seem to be "public", in that any of the forms that might be launched can access the variables using the _vfp.eval() method.
>
>However, if I create a new variable (call it "nEmployee")using _vfp.setvar() from within a form, and then close that form, and open another form, and try _vfp.eval("nEmployee"), it says that variable does not exist.
>
>Basically I want a way to create and set publicly available variables to exchange data between forms. I thought this might be a good way. And it is... as long as you make the _vfp.setvar() call from the main .prg file.
>

Are you expecting different behavior than PUBLIC gnEmployee would provide.

If you're doing OOP, public variables are a bad inter-object communication method, because the use of publics breaks encapsulation. If two forms need to exchange data, you can pass their own object refs if you need to have one for look at something 'inside' another, or better, create and pass parameter objects explicitly.

>Perhaps someone can teach me a better way to achieve this.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform