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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Property sheet data

Status
Not open for further replies.

andy0923

Programmer
Jul 26, 2002
65
US
Does anyone know a relatively clear and simple way of getting ALL of the methods and properties and values, etc from a form or formset?

I am aware of amembers() and have tried to adapt Ramani's formcompare but I am getting nowhere fast in streamlining and adapting it.

I was thinking in terms of recursion with the final output being saved in a table.

Either a form opened in designer or a running form would be OK. Thanks for any help.
 

Andy.

It's difficult to give firm advice without knowing what specific problems you are having. In general, I'd say that AMEMBERS() is the right approach.

You should be calling AMEMBERS() with 1 in the third parameter. This will give you a 2-column array.

Loop through this array. If the second column contains "Property" or "Method", add the contents of the first column to your output. If it contains "Object", call your method recursively, but this time call AMEMBERS() on the object whose name was present in the first column. I think that should give you what you want.

If you have FoxPro Advisor, you can find an example of using AMEMBERS() (but without the recursion) in my article "Add a Property Inspector to Your Toolkit" (September 2005).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike - You are definitely thinking along the lines of what I want.

I have always had a problem with the concept of recursion so I was wondering if you might know one or two lines of pseudo code which might make it clearer for me. I should be able to pick it up from that point.
 

Andy,

OK, I'll try. Basically, you need a function (or method) called, say, DrilDown. Let it accept a parameter, which is an object reference to any container object. The function calls AMEMBERS() as described above, using that object reference as its parameter. As it loops through the array, when it finds an object, it calls itself, passing that new object as a parameter. When it finds a non-object, it adds the details to a global array or cursor.

Basically, that's all there is to it. The first time you call the function, you would pass an object reference to the outermost container - the entire form.

Just a couple of things to keep in mind about recursion:

- Make sure the function will eventually exit; and

- Don't do it if you are likely to get a very large number of levels -- if you've got an extremely deep object hierarchy in this case. If you do, VFP will run out of stack space and blow up.

Hope this makes sense.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Andy,

Just to add ...

You asked for pseudo code. How about this (off the top of my head):

Code:
FUNCTION GetPEMs
* Gets all of a form's PEMs into a cursor

Create the cursor

DrillDown(obj. ref. to the form)

* Finished

ENDFUNC

FUNCTION DrillDown
LPARAMETER oSomeObject

AMEMBERS(aArray, oSomeObject, 1)
FOR EACH row in aArray
  IF aArray(row, 2) = "property" or "method"
    Add it to the cursor
  ELSE
    IF aArray(row, 2) = "object"
      Drilldown(object ref. to object whose name ;
       is in first column of the array)
    ENDIF
  ENDIF
ENDFOR

ENDFUNC

As I said, it's off the top of my head, and done in a hurry. Let me know if you have any more questions.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
You are just super. Just the thing to help me explore this.

I was able to try something similar, but not as precise and succinct as you put it. I ran into a problem identifying parent objects but I have to try what you wrote and see if it gives me further insight.

Thank you so much.

PS - You are also correct about the levels. I had modified Rani's code but it sort of exploded with forms which contained objects based upon foundation classes (ie find button). Will let you know if it works the way you put it.
 
Dear Mike - I was able to achieve what I set out to do, namely, duplicate the property list of a form or formset into a searchable table.

I modified the "drill down" function that you assisted me with but rather than call that recursively, I added another function. This function was able to create an array of fully qualified object names by recursive calls and then got the values of all the elements with GETPEM()

I would not want to bother you with reading my obtuse and unconventional code but would be happy to share it with you or anyone else who might be interested.

Thank you again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top