File Sort (SRT)
SRT(Array,Dimtovary,
Control);
Mnemonic
Data Type
.EN
BOOL
.DN
BOOL
.ER
BOOL
.LEN
DINT
.POS
DINT
Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE)
The SRT instruction sorts a set of values in one dimension (Dim to vary) of the
Array into ascending order.
Operands:
Relay Ladder
Operand
Array
Dimension to
vary
Control
Length
Position
Structured Text
The operands are the same as those for the relay ladder SRT instruction.
However, you specify the Length and Position values by accessing the .LEN and
.POS members of the CONTROL structure, rather than by including values in
the operand list.
CONTROL Structure
Description
The enable bit indicates that the SRT instruction is enabled.
The done bit is set when the specified elements have been sorted.
The error bit is set when either .LEN < 0 or .POS < 0. Either of these conditions also generates a major
fault.
The length specifies the number of elements in the array on which the instruction
The position contains the position of the current element that the instruction is accessing.
Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Type
Format
SINT
Array tag
INT
DINT
REAL
DINT
Immediate
(0, 1, 2)
CONTROL
Tag
DINT
Immediate
DINT
Immediate
Description
Array to sort
Specify the first element of the group of elements
to sort
Do not use CONTROL.POS in the subscript
Which dimension to use
Depending on the number of dimensions, the order
is:
array[dim_0,dim_1,dim_2]
array[dim_0,dim_1]
array[dim_0]
Control structure for the operation
Number of elements of the array to sort
Current element in the array
Initial value is typically 0
Chapter 8
385