Skip to content

declaration of arrays remains a total mystery

I have been making some progress in porting my IEC ST code from Horner-subspecies

to PLCnext...

I have zero clue how to declare arrays and / or strings

there are no instructions in the help system nor cues in the variable editor

It is such a common concept, it should be obvious how to declare them

Comments

  • To declare an Array or a custom-length string (ie anything other than max 80 characters) you must first create a type definition for the array or string type, in a Data Type worksheet. That type can then be used to declare a variable in a Data List table in a POU.

    You can create a new Data Type worksheet by right-clicking on the Data Types node in the Components area,.on the right of the PLCnext Engineer window.

    After that, the PLCnext Engineer Help gives a pretty good explanation, including examples.


  • Wow.. Thank you...

    I had already read those help pages but didn't extract and groc enough information to figure it out...

    First create a type in DataTypes Then create a variable in DataList Then create/reference the variable in the PoU

    Now I would have assumed that a type definition could be used for multiple arrays but apparently not...

    I had first created a type definition like this:  tMB_MJx_Status : ARRAY[0..3] OF UDINT;

    I could then create an array variable MB_MJ3_Status in DataList...

    when I attempted to create array variable MB_MJ2_Status in DataList it failed - turned into BOOL

    I just caved in to the idiosyncracies and created separate typedefs:

     tMB_MJ3_Status : ARRAY[0..3] OF UDINT;

    tMB_MJ2_Status : ARRAY[0..3] OF UDINT;

    What is the scoop on that ?

  • Here are screen shots from PLCnext Engineer using the Array and String examples shown in the help.

    Type definitions:


    Variable declarations, including multiple variables of the same type:


    Variable usage:


    This is how one type definition can be used to declare multiple variables.

Sign In or Register to comment.