Cancel
Showing results for 
Search instead for 
Did you mean: 

dealing with arrays

Builder
Builder

I am trying to create an array inside another array but I think I am not doing it right.

 

can someone help me with the attached file?

just run the method, it prints the content of the "array_abc". The problem is that it does not have the content that I programmed to have through append method.

 

I expected it should print:

[1,2,3,4,5,6,7,8,9,10] []

 

but it´s printing:

[[]] []

3 REPLIES

Re: dealing with arrays

Siemens Phenom Siemens Phenom
Siemens Phenom

You need to do it this way:

is
    array1: string[];
    array_abc: any[1,2]
do
    for local i := 1 to 10 loop
        array1.append(num_to_str(i));
    next;

    array_abc[1,1] := array1;

    print array_abc;
end;

 

You should call append only directly for local variables. When you do something like
array_abc[1,1].append("1")
Plant Simulaiton will first read out array_abc[1,1] and return a copy, and then append "1" to that copy. Finally Plant Simulation will discard that copy.

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: dealing with arrays

Builder
Builder

so to resolve it the way is to create a second array, perform the makearray on it and then copy it´s value to the array_abc[1,1], correct?

Re: dealing with arrays

Siemens Phenom Siemens Phenom
Siemens Phenom

Yes.

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.