Micro Focus QTP (UFT) Forums
RegisterUserFunc fails when one calls another - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: RegisterUserFunc fails when one calls another (/Thread-RegisterUserFunc-fails-when-one-calls-another)



RegisterUserFunc fails when one calls another - Archens - 08-22-2012

I've boiled the issue down to a simple example:
Code:
Public Function Foo(objW)
    Foo = objW.hwnd
End Function

Public Function Bar(objX)
    Bar = objX.Foo()
End Function

RegisterUserFunc "Window", "Foo", "Foo"
RegisterUserFunc "Window", "Bar", "Bar"

msgbox Window("nativeclass:=Shell_TrayWnd").hwnd
msgbox Window("nativeclass:=Shell_TrayWnd").Foo()
msgbox Window("nativeclass:=Shell_TrayWnd").Bar()

UnRegisterUserFunc "Window", "Foo"
UnRegisterUserFunc "Window", "Bar"

The Foo method works the first time, but fails when it's called from inside another RegisterUserFunced method.

Is it my code that's broken, or is it RegisterUserFunc?

Thanks!
Archens


RE: RegisterUserFunc fails when one calls another - sree.85 - 08-23-2012

Hay try to create a class for foo function and then create an object to that class


RE: RegisterUserFunc fails when one calls another - Archens - 08-23-2012

Foo is a getter method for the Window class. It doesn't make any sense to try to make it a class unto itself.