I have 2 arrays
array1 = Array("elem1", "elem2", "elem3")
array2 = Array("item1", "item2", "item3")
I then select one of the arrays
Randomize
dim refArray
if Rnd < 0.5 then
refArray = array1
else
refArray = array2
end if
And I make changes to its elements
refArray(0) = "foo"
refArray(1) = "bar"
Say Rnd is less than 0.5 and refArray = array1 executes. I would like that both array1 and refArray point to the same piece of memory, so when I make changes to refArray they should also be visible in array1.
After the code executes I would expect the contents of array1 to be: "foo", "bar", "elem3". But instead it remains unchanged.
The problem I am having is that vbs does not pass a reference to array1 or array2, but instead it duplicates it to a new array refArray, which gets the changes and leaves array 1 and 2 unchanged.
How can I get a reference to the array and have the changes made to refArray apply to the referenced object (normal Java/C usage)?
Thanks.