cancel
Showing results for 
Search instead for 
Did you mean: 

Can we pass a Object in argument of a function.

SOLVED
Highlighted
Regular Contributor

Can we pass a Object in argument of a function.

CAn we pass an object as an argrument of a function that is declared in another unit.

like

Unit1:

'USEUNIT Unit2

Sub Task()

Set Obj = ............whatever here........

Call Validate(Obj)

End sub

 

Unit 2:

Function Validate(value)

Value.Click  'here I want to check properties for "value".... but getting errror "Object is required"

 

End Function

 

How can I pass object and use their properties in another unit. ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Can we pass a Object in argument of a function.

When you get to the second function, you need to use something like eval() to tell it that what you passed isn't just a string.  There's an example in here:

https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/declared-in-another-unit/...

View solution in original post

6 REPLIES 6
Highlighted
Community Hero

Re: Can we pass a Object in argument of a function.

When you get to the second function, you need to use something like eval() to tell it that what you passed isn't just a string.  There's an example in here:

https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/declared-in-another-unit/...

View solution in original post

Highlighted
Regular Contributor

Re: Can we pass a Object in argument of a function.

Hi @Marsha_R Mars,

Thanks for your reply.

I had use Eval also for this  but It's not working.

 

Highlighted
Contributor

Re: Can we pass a Object in argument of a function.

Hi Kaiiii,

 

how about defining a variable of the object type on project level or project suite level, using that to store your object and as parameter for your function Validate.

 

Regards

S_Seydel

Highlighted
Regular Contributor

Re: Can we pass a Object in argument of a function.

Hi @S_Seydel ,

no.. it's not working.

still looking for  solution.

Highlighted
Community Hero

Re: Can we pass a Object in argument of a function.

Hi,

 

The sceleton of your code looks correct.

Most probably, as the text of the error says, object is not assignrd to the Obj variable and thus the code in the Validate() function cannot access object's properties.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Regular Contributor

Re: Can we pass a Object in argument of a function.

@Marsha_R @AlexKaras 

Hi

Thanks for your reply.

It's solved now. actually Object id gets chnaged after every execution so I used objectlabel property.

now it's working fine

Thanks @Marsha_R  for your suggestion.. it's working.