Hello,
I have a module like this :
MODULE TESTARRAY
VAR num MyArray{4} := [10,11,12,13];
ENDMODULE
and a sample of code like this :
Controller abbCont = new Controller();
RapidData abbMyArray = abbCont.Rapid.GetRapidData(“T_MOVE”, “TESTARRAY”, “MyArray”);
ArrayData abbADMyArray = (ArrayData)abbMyArray.Value;
IRapidData abbN1 = abbADMyArray[1];
IRapidData abbN2 = abbADMyArray[2];
IRapidData abbN3 = abbADMyArray[3];
IRapidData abbN4 = abbADMyArray[4];
abbMyArray.Dispose();
abbCont.Dispose();
At the end of my code, I have abbN1 = abbN2 = abbN3 = abbN4 = {13}.
You can see the problem in debug mode :
I can resolve the problem by using the following code instead :
Num abbN1 = (Num)abbADMyArray[1];
Num abbN2 = (Num)abbADMyArray[2];
Num abbN3 = (Num)abbADMyArray[3];
Num abbN4 = (Num)abbADMyArray[4];
but in my case, I have arrays of record type :
RECORD MyType
String Name;
Pos Point;
ENDRECORD
VAR MyType Points{x} = …;
And I have to copy each field of the record separately (inside my class derivating from UserDefined) and it’s quite painful.
So it’s the normal behavior or it is a bug?
The complete solution of my sample :
2008-07-29_122159_TpsViewTestArray.zip
Thank you!
Herv?.