Size In Elements (SIZE)

The SIZE instruction finds the number of elements (size) in the designated dimension of the Source array or string operand 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
  • String tags
Available Languages
Ladder Diagram
Ladder_Size In Elements (SIZE)_v1
FactoryTalk Design Studio
DSL - Ladder Diagram
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
SINT
INT
DINT
REAL
structure
String type
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
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
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
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.