|
Home > Archive > FoxPro Help and Support > May 2005 > Utility to return objects properties and their values
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Utility to return objects properties and their values
|
|
|
| Are there any free utililty to return objects properties and their values?
The main problem is that I cannot figure how to find all the existing
objects. If there is a way to find all the existing objects, I believe I can
use amembers() to get the properties and values.
Thanks.
| |
| Mark McCasland 2005-05-10, 8:25 pm |
| Go to http://www.universalthread.com and click the VFP Downloads link. Do a
search in the Summary combo for gofish and hit Enter. For VFP8 and 9, open
your project, then select the Code References option under the Tools menu.
"Peter" <Peter@discussions.microsoft.com> wrote in message
news:CDF57BEA-CFD7-4198-9965- 242A25ADC897@microso
ft.com...
> Are there any free utililty to return objects properties and their values?
> The main problem is that I cannot figure how to find all the existing
> objects. If there is a way to find all the existing objects, I believe I
can
> use amembers() to get the properties and values.
>
> Thanks.
| |
|
| Hi Mark,
I believe my question is not clear. I want to able to find all the existing
objects (the one created through createobject()) and return all their
properties
and values.
Thanks.
"Mark McCasland" wrote:
> Go to http://www.universalthread.com and click the VFP Downloads link. Do a
> search in the Summary combo for gofish and hit Enter. For VFP8 and 9, open
> your project, then select the Code References option under the Tools menu.
>
> "Peter" <Peter@discussions.microsoft.com> wrote in message
> news:CDF57BEA-CFD7-4198-9965- 242A25ADC897@microso
ft.com...
> can
>
>
>
| |
| Thomas Ganss 2005-05-11, 3:24 am |
| > I want to able to find all the existing
> objects (the one created through createobject())
> and return all their properties and values.
Nothing like brute force:
(from the hip, not tested)
Display Memory to CurrMemo.Asc
For lnRun = 1 to alines(laLines, FileToStr("CurrMemo.Asc"))
* work on Name if it is an object...
Next
Warning: Can only access currently visible objects.
But unless you write an object manager, which saves a reference
of every object during init to a globally accessible structure
objects hidden in the program stack (locals from functions calling
the current line, objects hidden by private) this will always happen.
HTH
thomas
| |
| Olaf Doschke 2005-05-11, 7:24 am |
| If you want this to log all memvars, objects etc.
if an error occurs, you'll get much too much
useless information about the state of your app.
Maybe concentrate on _screen activeform
or THIS, if using an .Error()-method.
Astackinfo() is quite useful to see from where
the user came to the point the error occured.
Bye, Olaf.
| |
|
| I'm trying to compare the objects between 2 applications (App1 and App2)
which create similar objects but they may have different properties and the
properties value may be different too. I want to know which App1's objects
and/or their properties are not in App2 and vice versa. But I don't find any
function/command to generate a list of existing objects into an array. The
only command is List Objects but it goes to printer or file.
"Olaf Doschke" wrote:
> If you want this to log all memvars, objects etc.
> if an error occurs, you'll get much too much
> useless information about the state of your app.
>
> Maybe concentrate on _screen activeform
> or THIS, if using an .Error()-method.
>
> Astackinfo() is quite useful to see from where
> the user came to the point the error occured.
>
> Bye, Olaf.
>
>
>
| |
| Olaf Doschke 2005-05-11, 8:25 pm |
| > only command is List Objects but it goes to printer or file.
Well, that's a start, isn't it?
LIST OBJECTS LIKE * TO FILE ("...") NOCONSOLE
lcObjects = FILETOSTR(...)
? STREXTRACT(lcObjects
,"Object:",CHR(13),1,3)
Although that won't give you objects atteched somewhere:
_screen.addobject("peter","custom")
LIST OBJECTS LIKE * TO FILE ("...") NOCONSOLE
=>File won't contain _screen.peter.
But such container objects like _screen have an objects array:
?_screen.objects(1).name
=>peter
amembers(laMembers,_
screen.objects(1))
....
There is no easy all-at-once solution.
Try to attach the objects of interest to a global application
object, this will make it easier to find them again. That's about
what Thomas Ganss also advised you, I can't really add more
to it.
Bye, Olaf.
| |
| Mark McCasland 2005-05-11, 8:25 pm |
| Sorry I did not understand that you meant objects that have been
instanciated. There is no easy way to get a "list" of all memvars except to
LIST MEMO TO FILE... You do not say what version of VFP you are using, but
ALINES() may then help you to get each line in the file into its own array
element. You can then parch each array element to find objects. Then you are
correct about the use of amambers function.
"Peter" <Peter@discussions.microsoft.com> wrote in message
news:9019C031-CA9C-411A-AC1B- B4913DC041D5@microso
ft.com...
> Hi Mark,
>
> I believe my question is not clear. I want to able to find all the
existing[color=darkr
ed]
> objects (the one created through createobject()) and return all their
> properties
> and values.
>
> Thanks.
>
>
> "Mark McCasland" wrote:
>
Do a[color=darkred]
open[color=darkred]
menu.[color=darkred]
values?[color=darkred]
believe I[color=darkred]
| |
|
| Hi Olaf,
Thanks for the info.
What is the value 3 in the last parameter of strextract()? I have never
used that function before.
This should work fine since the beginning delimiter "object:" is unique.
Peter
"Olaf Doschke" wrote:
> Well, that's a start, isn't it?
> LIST OBJECTS LIKE * TO FILE ("...") NOCONSOLE
> lcObjects = FILETOSTR(...)
> ? STREXTRACT(lcObjects
,"Object:",CHR(13),1,3)
>
> Although that won't give you objects atteched somewhere:
> _screen.addobject("peter","custom")
> LIST OBJECTS LIKE * TO FILE ("...") NOCONSOLE
> =>File won't contain _screen.peter.
>
> But such container objects like _screen have an objects array:
> ?_screen.objects(1).name
> =>peter
>
> amembers(laMembers,_
screen.objects(1))
> ....
>
> There is no easy all-at-once solution.
>
> Try to attach the objects of interest to a global application
> object, this will make it easier to find them again. That's about
> what Thomas Ganss also advised you, I can't really add more
> to it.
>
> Bye, Olaf.
>
>
>
| |
| Olaf Doschke 2005-05-13, 3:24 am |
| > What is the value 3 in the last parameter of strextract()? I have never
> used that function before.
Well, intellisense explains it all. It's a flag parameter, which I
can be set to
1 - case insensitive search of delimiters
2 - end delimiter not needed
or 3 - both
2 is good, if the last line output would be an object.
As there are always several additional lines this isn't
needed but in general helps.
So to make it more complete it could work this way:
LIST OBJECTS LIKE * TO FILE ("...") NOCONSOLE
lcObjects = lower(FILETOSTR(...))
for N = 1 to occurs("object:",lcObjects)
? getwordnum(STREXTRAC
T(lcObjects,"object:",CHR(13),N),1)
endfor N
> This should work fine since the beginning delimiter "object:" is unique.
be careful, in other language versions of the IDE the file created contains
other words, eg german VFP7 outputs "Objekt:" with LIST OBJECTS.
But if you force the exe to use vfpNenu.dll (N depending on the version
of vfp you use) this should work fine everywhere.
Bye, Olaf.
| |
| Boudewijn 2005-05-13, 8:34 am |
| [QUOTE]Originally
posted by Mark McCasland
[B]Sorry I did not understand that you meant objects that have been
instanciated. There is no easy way to get a "list" of all memvars except to
LIST MEMO TO FILE... You do not say what version of VFP you are using, but
ALINES() may then help you to get each line in the file into its own array
element. You can then parch each array element to find objects. Then you are
correct about the use of amambers function.
What's wrong with CompObj()? | |
| Mark McCasland 2005-05-13, 11:24 am |
| > > What's wrong with CompObj()?
That just returns .T. if the compared objects are identical. He was wanting
to get the names and values of the properties which compobj will not do.
|
|
|
|
|