以下工作正常:
PROGRAM PLC_PRG:
VAR
MyArray : ARRAY[0..1,0..5]OF USINT := [1,2,3,4,5,6,7,8,9,10,11,12];
i : INT;
j : INT;
END_VAR
// change to random values
FOR i:=0 TO 1 DO
FOR j:=0 TO 5 DO
MyArray[i,j] := i+j;
END_FOR
END_FOR
// Or individualy set numbers
MyArray[0,1] := 56;
MyArray[0,4] := 156;
END_PROGRAM
但是,如果我想在一行代码中修改所有值怎么办?
即以下是我想做的伪代码。(注意,它实际上不起作用)
PROGRAM PLC_PRG:
VAR
MyArray : ARRAY[0..1,0..5]OF USINT := [1,2,3,4,5,6,7,8,9,10,11,12];
bChange : BOOL;
END_VAR
IF bChange THEN
MyArray := [1,58,3,53,5,6,128,8,9,10,20,12];
END_IF
END_PROGRAM