Micro Focus QTP (UFT) Forums
How to retrieve ArrayList saved in Environment Variable - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to retrieve ArrayList saved in Environment Variable (/Thread-How-to-retrieve-ArrayList-saved-in-Environment-Variable)



How to retrieve ArrayList saved in Environment Variable - Gautam26 - 10-31-2013

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


RE: How to retrieve ArrayList saved in Environment Variable - basanth27 - 11-01-2013

Can you please post the code you have been trying?


RE: How to retrieve ArrayList saved in Environment Variable - Gautam26 - 11-05-2013

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


RE: How to retrieve ArrayList saved in Environment Variable - basanth27 - 11-06-2013

Does this work,

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



RE: How to retrieve ArrayList saved in Environment Variable - Gautam26 - 11-06-2013

Hi basanth

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

regards
Gautam


RE: How to retrieve ArrayList saved in Environment Variable - basanth27 - 11-07-2013

[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?


RE: How to retrieve ArrayList saved in Environment Variable - Gautam26 - 11-07-2013

Hi Basanth

could you precise the needful to be done ?

regards
Gautam


RE: How to retrieve ArrayList saved in Environment Variable - Parke - 11-07-2013

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


RE: How to retrieve ArrayList saved in Environment Variable - ssvali - 11-07-2013

Check below link. It might be helpful.

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