VB Script (VBS) array reference
I have 2 arrays
array1 = Array("elem1", "elem2", "elem3")
array2 = Array("item1", "item2", "item3")
I then select one of the arrays
Randomize
dim myArray
if Rnd < 0.5 then
myArray = array1
else
myArray = array2
end if
And I make changes to its elements
myArray(0) = "foo"
myArray(1) = "bar"
I want these changes to be made in one of my original arrays: array1 or
array2 (the one that was selected).
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 myArray, 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
myArray apply to the referenced object (normal Java/C usage)?
Thanks.
No comments:
Post a Comment