Saturday, July 16, 2011

How to call a function in one action from another action

We can do this QTP, by passing the function name with parameters as Input parameters

Following is the script in my "Action1"
RunAction "LibraryAction",0,"displayMsg(3)"
FuncReturnVal = RunAction ("LibraryAction", oneIteration, "sum 5,6,7,8")
msgbox FuncReturnVal

Create a New action called "LibraryAction", can created an input parameter call "function" of type string
Following is the script in my second action "LibraryAction"

func = Parameter("function")
Execute func
Public function displayMsg(str)
msgbox(str)
End Function

Function sum(a,b,c,d)
temp=a+b+c+d
exitAction(temp)
End Function

No comments: