| || |
- 1 Post By TmReddy
- 1 Post By NoUse4aName
- 1 Post By tarunlalwani
Set SwfWindow in a function
In an action I have a line of code:
Set myobject = swfWindow("A window")
It gives no complaints.
I put swfWindow(""A window"") in an external excel data sheet. The double quotes are doubled so that it holds on to the double quotes.
I bring it into a variable during the run.
Execute "DoSomething(variable)" <--simplified here for discussion.
In the function
I check that the "swfWindow("A window")" appears in a variable and it looks correct.
The variableInsideofFunction contains
Set myObj = variableInsideOfFunction
Kaboom it says that an object is required.
You need to do an eval. You are currently trying to assign a string to an object which won't work as you've found out.
I was reading the QTP online help. I thought that
Execute was to perform what is on the right side of the equal sign and then send a value back to the left side of the equal.
Eval is to do a comparison of the left and right side of the equal. I have not tried using Eval.
Is the Eval syntax the same as Execute?
How do I pass a logical OR name into a function?
I have Browser("hello").Page(world) in the OR. I want to tell the function to use this OR item in a function. How do I pass it into the function?
' Should this work?
You need to use execute function to make it work.
Here you go..
OrPath = "Browser(""xyz"").Page(""xyz"")"
' Should this work?
It looks good.
Let me try it.
Alternatively you could pass it to the function as an object.
Set myobj = browser().page()
Kevin, execute and eval are nearly same exception few things. Execute will treat a = to statement as assignment while eval will treat it as comparison. But to convert a string form of object you need to use eval, you can also use execute but eval id recommended
I got it to work with Execute. I did not try Eval.
I think passing the object in a userdefined variable may look better. And then I can avoid Execute and Eval.