3 - 30 3 - 30
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
Arrays are not limited to just numeric values. There are types of array that handle
characters as well. In addition, when using numeric type arrays, different types of
numbers can be defined, such as integers, single-precision, and double-precision.
(For details on defining variable types, see the sections for the DEFINT, DEFSNG, and
DEFDBL instructions.)
A$(n)
• • • • • • • • Indicates character array A$.
A%(n) • • • • • • • • Indicates integer array A%.
A!(n)
• • • • • • • • Indicates single-precision array A!.
A#(n)
• • • • • • • • Indicates double-precision array A#.
3.8.1 Number of dimensions in an array
The dimension of an array refers to the number of indices within the parentheses. The
following example shows one to three dimensional arrays.
Three-dimensional
(x,y,z)
C(0,2,1)
C(1,2,1)
C(2,2,1)
C(0,2,2)
C(1,2,2)
C(2,2,2)
A$(0)
A$(1)
A$(2)
B(0,0)
B(0,1)
B(0,2)
B(1,0)
B(1,1)
B(1,2)
B(2,0)
B(2,1)
B(2,2)
C(0,0,0)
C(0,1,0)
C(0,2,0)
C(1,0,0)
C(1,1,0)
C(1,2,0)
C(2,0,0)
C(2,1,0)
C(2,2,0)
One-dimensional
A$(x)
Two-dimensional
B(x,y)
…
…
…
For arrays with two dimensions or more, data can be extracted quickly by combining
meanings.
For example, before specifying the array A(x,y), the following is defined.
X=1
• • • • PLC
y=1
• • • • Production
schedule
X=2
• • • • Factory
automation
controller
y=2
• • • • Produced quantity
X=3
• • • • Robot
y=3
• • • • Achievement %
Then assign the data as
shown:
The number of PLCs produced to
A(1,2)
The target production of robots to
•
•
•
•
A(3,1)
This way, data can be extracted only
by matching the values in the
parentheses to the target elements
to reference the target data .
It is possible to define a maximum of 255 dimensions.
REMARK
It is possible to define a maximum of 255 dimensions, but in actuality, the amount of
memory may not be enough when too many dimensions are reserved.