Hi people
I'm running into a problem involving array reference.
In the following code, there is a simple class and one of its properties (namely "elements") is an array. Next, the class is instanciated and bound to the "var1" object variable. It should follow that "var1.elements" refers to the instance array.
Next, I try to assign a string value to the first 'cell' of the instance array :
var1.elements(0) = "hello"
and an anonymous array (through the Array(...) construct) is assigned to the second cell :
var1.elements(1) = Array("it's a beautiful day")
I can print out the values of var1.elements(0) and var1.elements(1)(0) without problems, but it's a different story attempting to modify the value of 'embedded' array :
var1.elements(1)(0) = "some other value"
... just doesn't work. It throws no errors, but the programmes behaves like var1.elements(1) returns a copy of the 'embedded' array and thus does not modify it. I mean that printing out var1.elements(1)(0) still displays "it's a beautiful day"
How come?
This behaviour doesn't occur using regular arrays instead of object variables :
dim var1(10)
var1(0) = Array("some value")
var1(0)(0) = "some other value" >>> the 'embedded' array assignment is correctly taken into account.
Thanks in advance for your input.class Test public elements() public sub Class_Initialize() redim elements(10) end sub end class REM ---------------------------------------------- dim var1 set var1 = new Test var1.elements(0) = "hello" var1.elements(1) = Array("it's a beautiful day") WScript.echo var1.elements(0), var1.elements(1)(0) REM >>> will display "hello it's a beautiful day"
var1.elements(0) = "yes it is" var1.elements(1)(0) = "and how are you?" WScript.echo var1.elements(0), var1.elements(1)(0)
REM >>> will display "yes it is it's a beautiful day"
- Edited by Grobu 10 hours 22 minutes ago -