26
4 LABELS
4.4 Arrays
4.4 Arrays
An array represents a consecutive accumulation of the same data type labels, under the same name.
Arrays can be defined by the elementary data types or structures or function blocks.
The maximum number of arrays differs depending on the data types.
Definition of arrays
■Array elements
When an array is defined, the number of elements, or the length of array, must be determined. For the range of the number of
elements, refer to the following.
Page 27 Maximum number of array elements
■Definition format
The following table lists definition format examples up to three dimensions.
The range from the array start value to the array end value is the number of elements.
How to use arrays
To identify individual labels of an array, append an index enclosed by "[ ]" after the label name.
For an array with two or more dimensions, delimit indexes in "[ ]" by using "comma (,)".
One-dimensional array Two-dimensional array
Number of array
dimensions
Format Remarks
One dimension Array of elementary data type/structure name (array start value .. array end value) • For elementary data types:
Page 23 Elementary data type
• For structured data types:
Page 28 Structures
(Definition example) Bit (0..2)
Two dimensions Array of elementary data type/structure name (array start value .. array end value, array start
value .. array end value)
(Definition example) Bit (0..2, 0..1)
Three dimensions Array of elementary data type/structure name (array start value .. array end value, array start
value .. array end value, array start value .. array end value)
(Definition example) Bit (0..2, 0..1, 0..3)
Type Specification example Remarks
Constant bLabel1[0] An integer equal to or greater than 0 can be specified. Decimal constant or hexadecimal constant can
be specified.
Device bLabel1[D0] A word device or double-word device can be specified.
Label bLabel1[uLabel2] The following data types can be specified.
• Word [unsigned]/bit string [16 bits]
• Double word [unsigned]/bit string [32 bits]
• Word [signed]
• Double word [signed]
Expression bLabel1[5+4] Expressions can be specified only in ST language.
bLabel1
[0]
[n]
[1]
Label name Indexes
…
bLabel2
[0,0] [0,1] [0,n]
[1,0] [1,1]
[m,0] [m,n]
…
…
…
…
……
…
…
…
Label name Indexes
bLabel1 [0] bLabel2 [0,3]
Label name Indexes