12-20-2011, 06:37 PM
Hi,
I'm using v10 of QTP with the java add-in and my AUT is a java swing application.
I'm accessing a number of native java methods of the application in order to retrieve data that can't be retrieved through the UI. One of the methods returns a java array object which I am able to read using mic_arr_get and write to using mic_arr_set.
However, I would like to append extra data to the array but QTP doesn't seem to allow the mic_arr_set to write extra items to it. Below is an example in code:
When QTP tries to execute the final line of that code snippet I get back a subscript out of range error, presumably because the original array I retrieved only contained two items.
Therefore, I have 3 questions:
Any help much appreciated!
David
I'm using v10 of QTP with the java add-in and my AUT is a java swing application.
I'm accessing a number of native java methods of the application in order to retrieve data that can't be retrieved through the UI. One of the methods returns a java array object which I am able to read using mic_arr_get and write to using mic_arr_set.
However, I would like to append extra data to the array but QTP doesn't seem to allow the mic_arr_set to write extra items to it. Below is an example in code:
Code:
'the getItems java method returns an array back to my retrieveItems QTP object - for the sake of argument lets say it returns 2 string items in the array and I output these into other variables
Set retrieveItems = myApplicationObject.getItems
item1 = retrieveItems.mic_arr_get(0)
item2 = retrieveItems.mic_arr_get(1)
'now I want to add a third item to the array
item3 = "this is my third item"
Set retrieveItems.mic_arr_set(2) = item3
When QTP tries to execute the final line of that code snippet I get back a subscript out of range error, presumably because the original array I retrieved only contained two items.
Therefore, I have 3 questions:
- Is there a way to count the number of items in the java array object that has been returned?
- Is there a way to append or delete items from the java array object?
- Bearing in mind I could get around this if I could create my own java array object and insert data into it, is there a way to create a new java array object?
Any help much appreciated!
David