Micro Focus QTP (UFT) Forums
Passing array of classes to parameter of action - 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Passing array of classes to parameter of action (/Thread-Passing-array-of-classes-to-parameter-of-action)



Passing array of classes to parameter of action - nvKy - 06-20-2012

Hello,

Goal: From the qtp main starting file, initialize an array of classes, and pass that array as a parameter to a re-usable action via a parameter.

Problem: I am not able to pass an array of classes to my re-usable action.

I have the main startup file which we will reference as “application_main”.

I have a re-usable action which we will reference as “personal_action”

Inside application_main, we have a call to InvokeApplication, proceeded by a few other declarations.

I am able to initialize my array of classes fine (variable name: “myArray”). I proceed to pass that array as a parameter as follows in my application_main:

RunAction “personal_action”, oneIteration, customParam1, customParam2, myArray

On the personal_action page, I have the ability to edit the parameter properties via Edit->Action->Action Properties. I select the Parameters tab. In it, I am able to define the incoming parameters as:

String, Boolean, Date, Number, Password, Any

Since “array” is not available, I select “Any”.

Upon running, I am prompted with this:

Code:
The type you specified for the ‘myArray’ parameter in your RunAction statement does not match the type defined in the action.

The array is the third parameter being passed, and the third parameter type is “any”.

My Question: Why am I not able to pass an array to an action from the main startup file? Does anyone know of a way to do this?

Any help is appreciated. Thank you.



RE: Passing array of classes to parameter of action - sshukla12 - 06-20-2012

Hi,

I had used global dictionary to transfer the array between action

Use the below code for reference and implement it as per ur requirement

Code in Action1:
Code:
Code:
d=Array("London","Boston","Newyork","Sanfransisco")        
For i=0 to ubound(d)
   GlobalDictionary.Item("Name"&i)=d(i)            
Next

Code in Action2:
Code:
Code:
x=GlobalDictionary.items
   For j=0 to ubound(x)
     msgbox x(j)
  Next


Let me know in case of any help required.

Regards,
Sankalp