Micro Focus QTP (UFT) Forums

Full Version: RegisterUserFunc fails when one calls another
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Hay try to create a class for foo function and then create an object to that class
Foo is a getter method for the Window class. It doesn't make any sense to try to make it a class unto itself.