Micro Focus QTP (UFT) Forums

Full Version: How to retrieve ArrayList saved in Environment Variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I created an ArrayList to store dynamic values and saved it in Environment variable.
While retrieving the ArrayList, I am facing Object mismatch exception.

Can any one help me?

regards
Gautam
Can you please post the code you have been trying?
Hi,
sorry for the delay to post the code. It's as below

Code:
Set array1 = CreateObject( "System.Collections.ArrayList" )
for i=0 to 10
array1.Add(test case name coming from Excel)
Exit for
Environment.Value("array1dtls")=array1

Following one  is retrieval part
Dim arryDtls
[b]arryDtls=Environment.Value("array1dtls")[/b]
MsgBox arryDtls.size

I am getting exception at "arryDtls=Environment.Value("array1dtls")" & Exception is as below

Run Error: Invalid procedure call or argument
Line (240): "arrayCheck=Environment.Value("arr1Dtls")".

Please, advise me what the needful can be done

regards
Gautam
Does this work,

Code:
msgbox Isarray(arryDtls)
msgbox arryDtls(0)
Hi basanth

It's not working as expected;
msgbox Isarray(arryDtls)------>False

regards
Gautam
[quote='Gautam26' pid='25339' dateline='1383730981']
[quote='basanth27' pid='25338' dateline='1383701270']
Does this work,

So, it means that it never came as an array. Can you use the IsArray to verify that it first stored as an array?
Hi Basanth

could you precise the needful to be done ?

regards
Gautam
Gautam26:

I believe only a string can be saved as an Environment Variable. If you do not want to use a global variable, you will need to convert your arrayList into a string. Then later call the string variable and use split to reuse the array.

hth,

Parke
Check below link. It might be helpful.

http://www.advancedqtp.com/old_forums/vi...php?t=1712