Welcome, Guest. Please login or register.
Login with username, password and session length

 
Advanced search

8966 Posts in 2277 Topics- by 14630 Members - Latest Member: scot_russell
 

Pages: [1]   Go Down
Print
0 Members and 1 Guest are viewing this topic.
Author Topic: Java array handling in QTP - with QTP internal functions !!! NEW!!!    (Read 846 times)
Tsachi Nimni
Active User
**
Offline Offline

Posts: 56


« on: June 15, 2008, 01:35:04 PM »

Here's a sample:
set comps = JavaWindow("SwingSet").JavaInternalFrame("Internal Frame Generator").Object.getComponents()
set currComp = comps.mic_arr_get(0(
msgbox currComp.toString()

The functions for handling java arrays:
mic_arr_get – receives an index and returns the item at that index in the array. Primitives are casted to objects.
mic_arr_set – receives an index and an object and sets the appropriate item in the array

also, for convenience:
mic_arr_get_int
mic_arr_get_char
mic_arr_get_double
mic_arr_get_long
mic_arr_get_short
mic_arr_get_byte
mic_arr_get_boolean
which converts the array item from Java primitive to the appropriate VBScript type

also:
mic_arr_set_int
mic_arr_set_char
mic_arr_set_double
mic_arr_set_long
mic_arr_set_short
mic_arr_set_byte
mic_arr_set_boolean
Logged
yassa
Administrator
Advanced User
*****
Offline Offline

Posts: 717



WWW
« Reply #1 on: June 15, 2008, 10:00:15 PM »

Sounds awesome, but haven't you left out the functions?
Logged

Yaron Assa

AdvancedQTP Site Administrator
Tsachi Nimni
Active User
**
Offline Offline

Posts: 56


« Reply #2 on: June 17, 2008, 01:00:16 AM »

hi yarron,
the function ALREADY EXISTS within qtp, they are not documented Smiley
u can just use it, as u use the .Click or the .Select or even the .Item(0) function
Logged
Tsachi Nimni
Active User
**
Offline Offline

Posts: 56


« Reply #3 on: June 17, 2008, 01:01:18 AM »

ho btw,
those function were given to me by Gal, the guy that actually develops the Java add-in, and he promised that they will add them to the documintation soon
Logged
yassa
Administrator
Advanced User
*****
Offline Offline

Posts: 717



WWW
« Reply #4 on: June 17, 2008, 02:07:31 AM »

WOW! That's awesome!

Then isn't it supposed to be JavaWindow("SwingSet").JavaInternalFrame("Internal Frame Generator").getComponents() (without the .Object. bridge to the runtime world)?

Anyway, with your permission, I'll publish this as a public QTip. OK?
Logged

Yaron Assa

AdvancedQTP Site Administrator
Tsachi Nimni
Active User
**
Offline Offline

Posts: 56


« Reply #5 on: June 17, 2008, 06:57:56 AM »

Hi yaron,
the .Object.getComponents() is a java command, which extracts the Array that holds the data we want, into a the QTP varliable X for example. same as we do in .Net we throw the array into a varliable and then refer to the varliable (Copy of the actual array)
and tehn we use the functions on that array
Java arrays are usually hidden from you, unless you use .object and drill down into them
and please publish this info o the benefit of all QTP users Smiley

Logged
AmandaJamin
User
*
Offline Offline

Posts: 2


« Reply #6 on: June 19, 2008, 12:10:06 PM »

How do you know the length of the java array?  In other words, if I keep using the mic_arr_get method, how will I know what the maximum index is so that I do not cause an array out of bounds exception?

Thanks for sharing this feature.  I like it a lot!

Amanda
Logged
Tsachi Nimni
Active User
**
Offline Offline

Posts: 56


« Reply #7 on: June 23, 2008, 02:06:59 PM »

i think the is a "mic_arr_get_length" method can't be sure because i don't have QTP at home Azn
will check at work and let you know on wednesday
Regards,
Logged
Tsachi Nimni
Active User
**
Offline Offline

Posts: 56


« Reply #8 on: June 25, 2008, 06:40:30 AM »

as promised i checked and it's "mic_arr_get_length"
good luck
Logged
Pages: [1]   Go Up
Print
Jump to: