Micro Focus QTP (UFT) Forums
Error while working with Function in QTP script - 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 Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Error while working with Function in QTP script (/Thread-Error-while-working-with-Function-in-QTP-script)



Error while working with Function in QTP script - mansis - 09-21-2012

Hi,

Following function I have preared by saving it in notepad file with .vbs extension.

----------------
Code:
Function Loadtime (a)
    For count = 1 To 999999
    Flag=a
If Flag = False Then
        Wait (1)
    Else
        count = 999999
    End If
Next
End Function
----------------
I have prepared following script by calling above function as follows-

----------------
Code:
URL = Datatable.Value("URL",Global)
User_name = Datatable.Value("User_name",Global)
Password = Datatable.Value("Password",Global)
Users = Datatable.Value("Users",Global)

systemutil.Run "iexplore",URL

'Load Login screen
a = Browser("InSync :: Login").Page("InSync :: Login").Image("topbanner").Exist
Call Loadtime (a)


Browser("InSync :: Login").Page("InSync :: Login").WebEdit("txtUsername").Set User_name
Browser("InSync :: Login").Page("InSync :: Login").WebEdit("txtPassword").Set Password
Browser("InSync :: Login").Page("InSync :: Login").WebButton("Login").Click

Browser("InSync :: Login").Close
----------------


After creating above test, I gone to File - Setting - Resources and clicked on the +(plus appears in green color) symbol and selected .vbs file in which function is described..

While runing script error "Type mismatch: 'Loadtime. Line(10): "Call Loadtime (a)" occurs.

Please let me know what is wrong in my script / function??

Thanks,
Mansi..


RE: Error while working with Function in QTP script - sshukla12 - 09-21-2012

Hi,

Try to pass Call LoadTime("a")

Regards,
Sankalp


RE: Error while working with Function in QTP script - charanbc - 09-21-2012

The only thing that i can think of is,
the name of the function is typed incorrectly in the script, recheck that the name of the function (not name of the vbs file) is the same in the vbs file and the script.

PS: using loadtime("a") will not be right as 'a' becomes a static string value with the quotes, you need it to be the variable 'a'. But you can try that anyway...


RE: Error while working with Function in QTP script - jesonvan - 09-21-2012

Could you try
Msgbox a
to confirm whether it is true or false?

U can try to write this function Directly in this script file first.
Perhaps qtp does not recognize this function from your vbs file.


RE: Error while working with Function in QTP script - jacosta - 10-02-2012

Hello, is passed as a parameter with descriptive programming the object, once you identify it runs on the for loop for review at runtime, and I do not see where you can change the value exist you send to the function .

Greetings.


RE: Error while working with Function in QTP script - hiregoudar - 11-20-2012

Hi Instead of calling function using "call" you have to use
ExecuteFile "path of the .vbs file"