Chapter 8
Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE)
Condition
Prescan
Rung-condition-in is false
Rung-condition-in is true
EnableIn is set
Instruction execution
Postscan
398
Execution:
Relay Ladder Action
The rung-condition-out is set to false.
The rung-condition-out is set to false.
The instruction executes.
The rung-condition-out is set to true.
N/A
The instruction finds the size of a dimension.
The rung-condition-out is set to false.
Example 1:
Find the number of elements in dimension 0 (first dimension) of array_a. Store
the size in array_a_size. In this example, dimension 0 of array_a has 10 elements.
Relay Ladder
Size in Elements
Source
Dim. To Vary
Size
Structured Text
SIZE(array_a,0,array_a_size);
Example 2:
Find the number of elements in the DATA member of string_1, which is a string.
Store the size in string_1_size. In this example, the DATA member of string_1 has
82 elements. (The string uses the default STRING data type.) Since each element
holds one character, string_1 can contain up to 82 characters.
Relay Ladder
Size in Elements
Source string_1.DATA[0]
Dim. To Vary
Size
Structured Text
SIZE(string_1.DATA[0],0,string_1_size);
Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Structured Text Action
No action taken.
N/A
N/A
EnableIn is always set.
The instruction executes.
The instruction finds the size of a dimension.
No action taken.
SIZE
array_a[0]
255
0
array_a_size
10
SIZE
'$00'
0
string_1_size
82