Editing java arrays in QTP - 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: Editing java arrays in QTP (/Thread-Editing-java-arrays-in-QTP) |
Editing java arrays in QTP - davey2582 - 12-20-2011 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: 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 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 RE: Editing java arrays in QTP - PrabhatN - 12-21-2011 Hi David, I am not sure if it will work for you but you can resize an array by "ReDim Preserve" statement. So after you get the array, try to increase the size of the array by this statement and then set the value. Learn about ReDim statement in the QTP Help file. RE: Editing java arrays in QTP - davey2582 - 12-21-2011 Hi Prabhat, Thanks for the suggestion, but unfortunately my java array is held as an object, rather than a variable so ReDim won't help here. Many thanks David |