Wednesday, October 18, 2017

Micro Focus UFT - How to pass parameters between actions (Action 1- MainScript to Action 2 - SubScript)

How to pass parameters between actions  (Action 1- MainScript  to Action 2 - SubScript)

[In Action 1] - MainScript
....
X = 1019786

VarX = DataTable("MCC_HSD""MainScript")

RunAction "SubScript [SubScript]", oneIteration, X
RunAction "SubScript [SubScript]", oneIteration, VarX

Print "After at Main Script value X : " &X
Print "After at Main Script value VarX : " &VarX
[In Action 2] - SubScript
....
Go to Action Properties; create an Input Parameter, say "X". and retrieve the variable X in Action 2.


Print "RunAction From Main Script to Sub value X : " &X
Print "RunAction From Main Script to Sub value VarX : " &VarX

X = 10
Print "Local Value of X :" &X

VarByValX =  Parameter("X")
Print "Before Manipulating the Value In Sub /Offer Script value X : " &VarByValX

VarByValX = VarByValX *1000
Print "After Manipulating the Value In Sub /Offer Script value X : " &VarByValX
------ *------ * ------ *------ *------ *------ *------
Now : Execute the MainScript
OUTPUT:
RunAction From Main Script to Sub value X :
RunAction From Main Script to Sub value VarX :
Local Value of X :10
Before Manipulating the Value In Sub /Offer Script value X : 1019786
After Manipulating the Value In Sub /Offer Script value X : 1019786000
RunAction From Main Script to Sub value X :
RunAction From Main Script to Sub value VarX :
Local Value of X :10
Before Manipulating the Value In Sub /Offer Script value X : 3
After Manipulating the Value In Sub /Offer Script value X : 3000
After at Main Script value X : 1019786

After at Main Script value VarX : 3

No comments:

Post a Comment