Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Acessing Controls by Reference or Name
Message
From
04/01/2001 09:54:36
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Title:
Acessing Controls by Reference or Name
Miscellaneous
Thread ID:
00459325
Message ID:
00459325
Views:
56
Hello!
This is my first question in this great site.

To cut costs of app management I use the PARENT property to access objects, with this when I move a group of objects, for example to a container, my source code doesn’t need to be change. Well, but this isn’t always solution, therefore I have created an array with the reference of the objects I need to access. In the init event of the objects I check my property FormSetRef and create a reference of the object in the array (property) ObjRef and the name In the ObjId. With this I can use the next code:

THISFORM.ObjRef (“mycontrol”). VISIBLE = .T.

I know that I can’t use methods with this kind of syntax, but ObjRef isn’t a method, it's an array… Yes I know that I’m passing a string and not a numeric to the array item number but I've an ObjRef_Acess method that controls that!

At the beginning of my adventure, I only need to destroy this references in the Destroy event of the form, because, with the ref. in memory (in this property) the form doesn’t close becouse ref. of some form controls exist in the array. This was result for a short time. Because when I start using this more, the same problem occurs and the form doesn’t close.
Well, I discover that is because I’m returning the objects references in a #define clause and when I use this, the control reference, is not local, is something else that makes FOX crazy. If you know why, please tell me!!!

To this thing works, I must assign the return value (the objref) of the ObjRef property to a local var (type “O”). My main question is: It’s the best way work with the reference, or use the “path” of the object (Ex. THISFORM.pgf1.pagfe2.opg1.opt1) in a string and use the macro operator:

LOCAL loObject = EVAL(“THISFORM.pgf1.page1.mytextbox”)
LcDummy = lObject.VALUE

OR use like this

LOCAL lcObject = “THISFORM.pgf1.page1.mytextbox”
LcDummy = &lcObject..lcDummy

What’s the fastest process, what’s the best, advantages, disadvantages that you know!

THANKS!
And sorry the complex description of the subject.
Next
Reply
Map
View

Click here to load this message in the networking platform