Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question about a public variable
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00285721
Message ID:
00285726
Views:
15
>I have a form where I want some options to be displayed on the main menu. So I create a new menu pad from this form's init, and release the menu pad from the form's release method. I want to run one of the form's methods when a menu bar is selected from this new menu pad.
>
>I tried the following command: oThisform = thisform so that I could reference "thisform's" methods. I get the error oThisform does not exist. I assume that this is because the form has a private datasession.
>
>Anyway, I then declared oThisform to be public and then everything seems to work fine.
>
>My question is, is there a problem with doing this? Is this defeating the purpose of having the form in a private datasession? Or maybe I'm worrying about nothing and it is ok to do this and then release oThisform from within the form's release method?
>
>thanks,
>Paul

That's not problem of datasession. It's problem of scope. Local variables (including oThisform, if you don't declare it public) live within the snippet (method,event,procedure) they were created, and therefore menu procedure does not see variables created within some form snippet. The way to handle it is to use properties (public variables make app environment dirty) of some object that is visible for both form and menu. For example, if you keep reference to form as some property of application object, you may always use to check/call form PEMs from menu:
oApp.myform.mycontrol.visible=.f.
Edward Pikman
Independent Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform