Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get an Form/Object Reference via a Prg Class
Message
 
To
11/01/1999 14:57:37
Anthony Test
Microcomputer Engineering Services, Llc
Huntington Beach, California, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00174742
Message ID:
00174832
Views:
33
Hi Anthony,

>I used your 'Brutal Force' suggestion and it works great! I waited to send this reply until I had a chance to test it out.

If you rely on the forms collection you have to make sure that you user can't start the form multiple times. Otherwise the loop will always found the last launched form.

Just to expand on Edwards reply to you. Whenever you launch a SCX based form without specifiying the NAME clause, VFP create a memory variable with the same name as the SCX file. This variable is public when you launch it from the command window and private when launched from within a program or menu. What happens to you is this. The user selects the menu, the code is executed and a reference variable is created. But then the menu procedure returns and like any other procedure it releases all private variables. That's why you can't find the reference when you launch the form from the menu, but are able to access it when you run the form from the Command Window.

The key to understand this behavior is that you need a _reference_ in order to access a form. A reference is either a relative reference like THISFORM, or must be stored within a variable. You can't just use the name of the form or the SCX file (with the exception above).

There's a third way (and many more, of course *g*). Create a public variable and use the name option as in:

PUBLIC myForm
DO FORM AnyForm.SCX NAME myForm LINKED

From then on you can use myForm to access this form.

Christof
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform