Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array as an environment variable.....
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi All,

I am facing an issue in my script.Actually i have a function which is common in few scripts. In which i am assigning values in an array.
In a script the value of this array from this function has to be used in another funstion in the same script. But i am enable to implement this as this array becomes local to the function so it's value can not be used in another function.
That's why i want to make this array as a global array(variable).o that value from one function can be used in another function in same script.
And for this i am thiniking to make this array a an environment variable.
But i donn know how to make it as environment variable and then save any value in an envirionment array variable...

Please help me out to resolve this problem..

Thanks,

Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi Rachna,

You can achieve this by returning array through your function.

Syntax:
function name = array

It can also be done using Dictionary object (Scripting.Dictionary).

Please let me know if you are not able to reach the solution.
Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
What if the array is passed to the function as a parameter when it is called using call by value or call by reference?
Reply
#4
Solved: 11 Years, 4 Months, 3 Weeks ago
Environment variable for a array is a ruled out option. Why are you not declaring it as a global variable?
Public TestArray(10)
??
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#5
Solved: 11 Years, 4 Months, 3 Weeks ago
Thanks for reply. I have tried the same still if i'll use this array in function a message that 'Type mismatch ' is getting populated..Sad
Reply
#6
Solved: 11 Years, 4 Months, 3 Weeks ago
I used something like this in one of my code and it worked for me.

Code:
Dim avlprglist(4)
var=GetAvailProgram(searchText,avlprglist)
var=SelectProgram(avlprglist)
FunctionGetAvailProgram(searchText,avlprglist)
  ....code....
  avlprglist=assign the array I created here
End Function

This can also be obtained as a return value for function as some one suggested above like:
Code:
var=yourFunction()
x=newFunction(var)
Function yourFunction()
  --code---
  yourFunction=assign the array
End Function

Another thing is we have to define an array with range definitely before using it.

Hope this helps
Reply
#7
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi Rachna ,see if the below code helps.Its not throwing type Mismatch error
Code:
public Arr
arr=Mytest
msgbox Arr(0)
Call mytest1( arr)
' Function Defination
Public function Mytest()
  Mytest=Array(1,2,3,4)
End Function
Public function mytest1(Byref arr )
   msgbox arr(1)  
End Function
Regards,
Ravi
Reply
#8
Solved: 11 Years, 4 Months, 3 Weeks ago
Check the below link. It might be helpful.

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Not able to get the list of items in Delphi Combobox Environment Object Raj Aryan Singh 3 2,345 02-04-2020, 12:32 AM
Last Post: Raj Aryan Singh
  how to get relative path by using testdir environment variable Sathyaprasad 1 1,984 11-30-2017, 02:21 AM
Last Post: supputuri
  environment variable path for qc automation2012 0 2,890 01-18-2015, 08:18 AM
Last Post: automation2012
  Select does not work together with Environment.Value qtped 7 4,136 02-14-2014, 12:46 PM
Last Post: supputuri
  How to convert a single dimension array to two dimensional array venkatesh9032 3 5,626 02-10-2014, 03:07 PM
Last Post: pranikgarg

Forum Jump:


Users browsing this thread: 1 Guest(s)