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

calling a method fop

Status
Not open for further replies.

shresthaal

Programmer
Jun 8, 2005
62
US
I have a form that has multiple container objects of the same type. Lets say the container objects name is conobj.

Currently the form has two conobj objects. conobj1 and conobj2.

Now i have a do while loop that cycles thru these objects to see which one i can use. The conobjs has a property that returns .t. or .f. .t. stating that the obj cannot be used and .f. stating it can. Now to achieve this I store
"thisform.conobjs" in an object say ctmp then i append a number which is a counter to state which obj it is for example if nctr in the do while loop = 1 then its conobjs1 and this is how i do it
ctmp = ctmp + alltrim(str(nctr)) + ".propertyname"
and then when i do &ctmp it works fine. After this i have to call a method of conobj1 from the form and i did the same thing
ctmp = "thisform.faxobj" and then ctmp = ctmp + alltrim(str(nctr)) + ".methodname("'"+ param1 + "," + param2)
but when i try to call it like &ctmp there is an error o
 
shresthaal

I was struggling a little to follow your code. Can you respond with the whole code you are using.

If I understood your thread correctly, I would do it this way:

To find out which object to use I would do this:
Code:
FOR Counter = 1 TO THISFORM.ControlCount
  IF THISFORM.Controls(Counter).Name = [conobj] AND NOT THISFORM.Controls(Counter).PropertyName
    UseObj = THISFORM.Controls(Counter)
    EXIT
  ENDIF
ENDFOR
You should then be able to call the method of the object using
Code:
&UseObj..MethodName("'"+ param1 + "," + param2)


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I meant to say that you don't actually say what the error was, unless something went wrong with the posting - it does look odd with that enormous space.

Stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top