11 - 58 11 - 58
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
DIM
Instruction
DIMension
• Specifies the size of a dimension and assigns a memory area necessary for the array.
DIM array variable name (numeric expression [, numeric expression] …) [, array variable
name (numeric expression [, numeric expression] …) ]
array variable name
• • • •
Specify the name of a variable used as an array.
Syntax
numeric expression
• • • •
Specify the size of the array specified by the array
variable name.
Examples
DIM A(2, 2)
• • • •
Indicates a two dimensional numeric value array.
A(0, 0)
A(1, 0)
A(2, 0)
A(0, 1)
A(1, 1)
A(2, 1)
A(0, 2)
A(1, 2)
A(2, 2)
• The DIM instruction specifies the size of an array variable and assigns a memory area
necessary for the array.
• The following arrays can be defined:
A(n)
• • • •
Numeric value array
A%(n)
• • • •
Integer array
A!(n)
• • • •
Single precision array
A#(n)
• • • •
Double precision array
A$(n)
• • • •
Character array
Description
• <numeric expression> may be specified up to 32767. An insufficient memory occurs if too
large memory area is assigned.
• When using an array, a “Subscript out of range” error occurs if the index of the array
variable name is larger than the value of <numeric expression> specified by the DIM
instruction.
• The minimum value of <numeric expression> is 0.
• If an array variable name, which is not specified by the DIM instruction, is used, 10 is
assumed for the minimum value of its index.
In some instructions of AD51H-BASIC, there are some that do not correspond to
the implicit array declarations as shown above.
It is recommended that arrays be used after declaring variables by the DIM instruction.