FX Series Programmable Controlers Applied Instructions 5
5-77
5.7.10 SORT (FNC 69)
Operation:
This instruction constructs a data table of m
1
records with m
2
fields havin
g
a start or head
address of S. Then the data in field nis sorted in to
numerical order while retainin
g
each individual
records inte
g
rit
y
. The resultin
g
(new) data table is stored from destination device D.
Points to note:
a) When a sort occurs each record is sorted in to ascendin
g
order based on the data in the
selected sort field n.
b) The source (S) and destination (D) areas can be the same BUT if the areas are chosen to
be different, there should be no overlap between the areas occupied b
y
the tables.
c) Once the SORT operation has been completed the ‘Operation Complete Fla
g
’ M8029 is
turned ON. For the complete sort of a data table the SORT instruction will be processed
m1times.
d) Durin
g
a SORT operation, the data in the SORT table must not be chan
g
ed. If the data is
chan
g
ed, this ma
y
result in an incorrectl
y
sorted table.
e) The SORT instruction ma
y
onl
y
be used
ONCE
in a pro
g
ram.
From the example instruction and the ‘data table’ below left, the followin
g
data manipulation
will occur when nis set to the identified field
Mnemonic Function
Operands
Program steps
S
m
1
m
2
Dn
SORT
FNC 69
(SORT
Tabulated
Data)
Data in a defined
table can be
sorted on selected
fields while
retainin
g
record
inte
g
rit
y
D
K, H
Note:
m1= 1 to 32
m2= 1 to 6
D
K, H
D
Note:
n = 1 to
m2
SORT:
11 steps
X21
SORT
D100
K 4
[ S ] [ D ]
K 3
D100
K 2
nm1 m2
4
1
2
3
1 2 3
FIELD (m2)
(D100)
32
(D101)
74
(D102)
100
(D103)
7
(D104)
162
(D105)
6
(D106)
80
(D107)
34
(D108)
4
(D109)
200
(D110)
62
(D111)
6
R
E
C
O
R
D
(m
1
)
4
1
2
3
1 2 3
FIELD (m2)
(D100)
74
(D101)
7
(D102)
100
(D103)
32
(D104)
6
(D105)
34
(D106)
80
(D107)
162
(D108)
200
(D109)
6
(D110)
62
(D111)
4
R
E
C
O
R
D
(m
1
)
4
1
2
3
1 2 3
FIELD (m2)
(D100)
7
(D101)
32
(D102)
74
(D103)
100
(D104)
34
(D105)
162
(D106)
6
(D107)
80
(D108)
6
(D109)
4
(D110)
200
(D111)
62
R
E
C
O
R
D
(m
1
)
Ori
g
inal
Table1st table sort when n= 2
2nd table sort when n=1