Size In Elements (SIZE)

The SIZE instruction finds the number of elements (size) in the designated dimension of the Source array and places the result in the Size operand. The instruction finds the size of one dimension of an array.
The instruction operates on:
  • Arrays
  • Arrays in a structure
  • Arrays that are part of a larger array
Available Languages
Ladder Diagram
Ladder_Size In Elements (SIZE)_v1
Structured Text
SIZE(Source,Dimtovary,Size);
Operands
IMPORTANT: Unexpected operation may occur if:
  • Output tag operands are overwritten.
  • Members of a structure operand are overwritten.
  • Except when specified, structure operands are shared by multiple instructions.
There are data conversion rules for mixing numeric data types within an instruction. See Data conversions.
Ladder Diagram
Operand
Data Type
Format
Description
Source
Can be specified as ANY
Array tag
First element of the array on which the instruction is to operate
Tags that are not array are not accepted during verification
Dimension to Vary
DINT
immediate
(0, 1, 2)
Dimension to use:
  • For the size of first dimension, enter 0.
  • For the size of second dimension, enter 1.
  • For the size of third dimension, enter 2.
Size
SINT
INT
DINT
REAL
tag
Tag to store the number of elements in the specified dimension of the array
See Structured Text syntax for more information on the syntax of expressions within structured text.
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See Index through arrays for array-indexing faults.
Execution
Ladder Diagram
Condition/State
Action Taken
Prescan
N/A
Rung-condition-in is false
Set Rung-condition-out to Rung-condition-in.
Rung-condition-in is true
Set Rung-condition-out to Rung-condition-in.
The instruction executes.
Postscan
N/A
Structured Text
Condition/State
Action Taken
Prescan
N/A
Normal execution
Set Rung-condition-out to Rung-condition-in.
The instruction executes.
Postscan
N/A
Examples
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.
Ladder Diagram
FTStudio-SIZE-LD-EX1-V1
Structured Text
SIZE(array_a,0,array_a_size);
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal