2 - 13 2 - 13
MELSEC-Q
2 THE BASICS OF AD51H-BASIC
2.8.2 Array variables
• Arrays are groups of values that can be referenced using the same variable name.
• Each element within an array is referred to via the array variable name. Array
variable names can be used within BASIC instructions and functions in the same
manner as variables.
• An array has a number of elements, a number of dimensions, and a value type. The
specification of the value type is the same as for variable names, but the number of
dimensions and number of elements usually require declaration.
• An array is declared using the DIM instruction. For example,
10 DIM A$(3)
• • • • • •
Declares a one-dimensional array with the name A$
that uses character strings as values.
20 DIM B(3,2)
• • • • • •
Declares a two-dimensional array B that uses numeric
values as values.
• An array variable name has the same number of subscripts as the number of
dimensions in the array. Subscripts indicate the location of each element within an
array. The range of values that subscripts can have is from 0 to 32767.
For example, each element of arrays A$ and B above can be referenced using the
following array variable names.
Array A$
Array B
A$(0)
B(0,0)
B(0,1)
B(0,2)
A$(1)
B(1,0)
B(1,1)
B(1,2)
A$(2)
B(2,0)
B(2,1)
B(2,2)
A$(3)
B(3,0)
B(3,1)
B(3,2)
• A maximum of 255 dimensions can be used in one array.
• If an array variable name is referenced before the array is declared using the DIM
instruction, it is assumed that the array has a maximum value of 10 for the
subscripts.
For example, consider the following instruction:
30 C(3)=200
If an array declaration for C is not present before executing the instruction, it is
assumed that the array is one-dimensional and has elements ranging from C(0)
through C(10).
This implicit array declaration is possible only with arrays of two dimensions or less.
Some AD51H-BASIC instructions do not support the implicit array
declaration described above.
It is recommended to use arrays after declaring them using
the DIM instruction.
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...