Cx programmer-Structured text, Array assignement

2.3k views Asked by At

i'm learning structured text, to program with Cx-programmer, an Omron software.

i' ve looked around but i can't find a way to assign multiple element to an array, i've tried this soluion, but it doesn't work,

this is Arrays declaration(internals variables):

Name              Data type   Initial value
SenCheck_Array      BOOL[8]     FALSE       
SEN                 INT[2]       0          

Array of INT:

     SEN[1...2]:=[1,2];

Array of BOOL:

      SenCheck_Array[0...7] := [ S_LF,S_LS,S_LH2O,S_LO,S_Col ,S_BAR,S_TAP,S_ET ] ;

The error is the same:

ERROR:  Missing ]

i succeded in assigning element singularly, but i need to assign them in a single line.

Any help is apreciated:)

P.S: i'm using cx programmer educational edition.

1

There are 1 answers

7
dergroncki On

Edit: This example (showing the declaration part of the SCL block code) is only valid for Siemens PLCs.

To initialize an array the values must be separated by a comma without square brackets:

CONST
    // Constants
    S_LF := TRUE;
    S_LS := FALSE;
    S_LH2O := FALSE;
    S_LO := FALSE;
    S_Col := TRUE;
    S_BAR := TRUE;
    S_TAP := TRUE;
    S_ET  := TRUE;
END_CONST

VAR
    // Static Variables
    SEN: ARRAY[1..2] OF INT := 1, 2;
    SenCheck_Array: ARRAY[0..7] OF BOOL := S_LF, S_LS, S_LH2O, S_LO, S_Col , S_BAR, S_TAP, S_ET;
END_VAR