Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a FUNCTION or Property to Get the "Complete Address" of a Form Control 2

dylim

Programmer
Joined
Dec 12, 2001
Messages
189
Location
PH
Hi Guys,

Is there some VFP function or Property that will return the "complete address" of a form control?

This is what I mean:

Suppose I have a textbox named txtFirstname, which is inside Page1 of pgfMain found in a form. How can I get its complete address::

Code:
ThisForm.pgfMain.Page1.txtFirstname

My advanced apologies if this may be stupid or obvious. Having some brain fog lately. haha
 
have a look at parent object properties in the help - in the click of a command button on the same page frame

Code:
messagebox(this.parent.name)

should return Page1, and a recursive call to that until you reach the top of the tree would give you what you need
 
Interesting question. What does the Parent property offer you?

I might play around with this some more when I go in to the office in a few hours,

Gary
 
Hi Guys,

Is there some VFP function or Property that will return the "complete address" of a form control?

This is what I mean:

Suppose I have a textbox named txtFirstname, which is inside Page1 of pgfMain found in a form. How can I get its complete address::

Code:
ThisForm.pgfMain.Page1.txtFirstname

My advanced apologies if this may be stupid or obvious. Having some brain fog lately. haha
I assume you use Thor? One of the brand new tools that you can install with Thor is Sidekick. It comes with a feature ES (EditSource Builder) which gives you exactly what you want.
 
Create some custom class for each standard class (like textbox, listbox, ....) and then in it create a method called GetPath in which you put the next code:

loParent = this.Parent
lcpath = this.Name
DO WHILE vartype(loparent) ='O'
lcpath = loParent.name + '.' + lcpath
IF LOWER(loparent.parentclass)<>'form'
loParent = loparent.parent
ELSE
loparent = ''
endi
ENDDO

lcpath= 'thisform' + SUBSTR(lcpath,AT('.',lcpath))
return lcpath
 
Hi Dylim,

you can use SYS( 1272, THIS ) for the control location.

Thomas
 
To all who replied,

SYS( 1272, This ) is what I am looking for!

Thanks SoftArt
 
The Hacker's Guide gives a hint this function is useful only for debugging and developer tools, not in production code.

So when you aim to use this in production code rethink why and for what you're intending to use this. First of all, if you have an object reference, you can act on the object, there's no need to use the fully qualified name, instead. Then on top of that, SYS(1272) gives a form name by the name property of the form, which is not necessarily unique, forms created by createobject("form") all have the name "form", not even form1, 2,3, etc. And SCX forms started by DO someform.scx don't get referred to as someform, but whatever you put into the name property in the form designer, which defaults to form1, so you can have multiple form1 forms.

You can't make use of the full name path anyway, unless you know how to address the form root object. Within the form you can always switch that to THISFORM, of course, but for addressing something from outside, like from a function or another form, you can't use that, of course.

One debugging use for SYS(1272) is adding SYS(1272,SYS(1270)) into the watch window, it comes with a problem attached, though, you can't close a form as this watch window entry will cause an extra reference on something in the form, which makes it not release, so you'd need to delete it from the watch window before being able to close that form again.
 
Last edited:
The Hacker's Guide gives a hint this function is useful only for debugging and developer tools, not in production code.

So when you aim to use this in production code rethink why and for what you're intending to use this. First of all, if you have an object reference, you can act on the object, there's no need to use the fully qualified name, instead. Then on top of that, SYS(1272) gives a form name by the name property of the form, which is not necessarily unique, forms created by createobject("form") all have the name "form", not even form1, 2,3, etc. And SCX forms started by DO someform.scx don't get referred to as someform, but whatever you put into the name property in the form designer, which starts with form1.

So you can't make use of the full name path anyway, unless you know how to address the form root object. Within the form you can always switch that to THISFORM, of course, but for addressing something from outside, like from a function or another form, you can't use that, of course.

So one debugging use for this is addiing SYS(1272,SYS(1270)) into the watch window, it comes with a problem attached, though, you can't close a form as this watch window entry will cause an extra reference on something in the form, which makes it not release, so you'd need to delete it from the watch window.

Chriss,

I had an OLD form class used for generating reports wherein I use as part of my Validation routine the 'direct addressing' of a form control that has an invalid value.

The Validate routine will go through all controls (textboxes usually). If the Value is invalid, I passed the offending control to an error handling method its 'direct address' as a character string parameter. For example, like "Form1.txtCusname", which is kinda tedious. So SYS( 1272 ) does this effortlessly. When my error handling catches this "Form1.txtCusname", I transform it into an object then invoke its SetFocus():

Code:
loControl = EVALUATE( "Form1.txtCusname" )
loControl.SetFocus()

Now, though, I have already changed it to cycling thru the ThisForm.Controls array so I do not need to manually type the offending control, or use SYS(1272) altogether.

Thanks.
 

Part and Inventory Search

Sponsor

Back
Top