639
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Tracking Instructions
3
RSORT4
z Operand Specifications
Flags
Function
The number of records specified by C starting from the record specified by S are sorted according to
the data in the specified location (4 words). When the sort operation has been completed, the Carry
Flag will turn OFF and the number of records that were sorted will be output to D1. If outputting to an
index register is specified in C+4, one address higher than the PLC memory address of the last word in
the sorted records is output to the specified index register. The sort direction is specified as ascending
or descending in C+3.
If split sorting is enabled in C+3, the sort will be executed over multiple cycles. The Carry Flag will be
ON while the sort operation is being executed and will turn OFF when the sort operation has been
completed. If the execution condition of RSORT4 turns OFF before the sort operation has been
finished, the sort will be continued the next time the execution condition turns ON.
Precautions
Always clear C+7 to 0 before starting to sort.
Area
Word addresses
Indirect DM/EM
addresses
Con-
stants
Registers Flags
Pulse
bits
TR
bits
CIO WR HR AR T C DM EM
@DM
@EM
*DM
*EM
DR IR
Indirect
using IR
TK CF
C
OK OK OK OK OK OK OK OK OK OK ---
---
--- OK
--- --- --- ---
S
D1 OK
D2 --- --- --- --- --- --- --- --- --- --- OK --- OK ---
Name Label Operation
Error Flag P_ER • ON when the record length in C+1 is not between 4 and 1,024, inclusive.
• ON when the number of records specified in C times the record length in C+1 is greater than
32,768.
• ON when the number of records specified in C times the record length in C+1 is 0.
• ON when the sort data offset in C+2 is greater than four less than the record length in C+1.
• OFF in all other cases.
Carry Flag P_CY • ON while the records are being sorted.
• OFF when the sort operation has been completed.