Micro Focus QTP (UFT) Forums
Passing a value as an argument in function - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Passing a value as an argument in function (/Thread-Passing-a-value-as-an-argument-in-function)



Passing a value as an argument in function - qtpctc - 08-18-2009

Hi All,
I am new to qtp and implemented one functionality as like below
Function:

Code:
Function loginpage(m)
Dialog("Login").WinEdit("Agent Name:").Set m
Dialog("Login").WinEdit("Password:").SetSecure "4a8a8fcc491dd5ddab8dcf1970f281492644fe42"
End Function

Script:
Code:
Call loginpage(filight)
Dialog(“Login”).WinButton(“Ok”).Click

In the above script I have given a argument “filght” that is “filght is replaced by “m”
My way of thinking:
“Filght” need to be taken as “Agent Name:”

Actual one:

Here it is not taking “filght” in to “Agent Name” field but password field is taking as "mercury"

Thanks in advance
qtpctc


RE: Passing a value as an argument in function - Saket - 08-18-2009

Hi qtpctc,

there is no issue with your function. The way you have called this is causing the issue
in the statement
Call loginpage(filight)
you need to pass a value which the argument(m) of your function is accepting.
so when you pass filight QTP treats is again as a variable which is not defined in your script.

so you will need to pass this as
Call loginpage("filight")

Hope you get my point.


RE: Passing a value as an argument in function - qtpctc - 08-18-2009

Thanku very much, which is working thanks alot....................