UD70
Issue code: 70nu2
4-4
DPL programming
Arrays
Arrays are collections of variables of the same type (integer or floating
point) under the same name. Note that only single-dimension arrays
are allowed.
Each element (individual component) of an array is, in effect, a separate
variable. An element is accessed by a program by specifying the array name,
then placing the element number in square brackets [ ]
[ ] after the array name
The two basic forms of arrays are as follows:
Dynamic
arrays
Dynamic arrays can be set up and changed by DPL programs. A dynamic
array must contain, integer variables or floating-point variables, but not
both types of variable.
A dynamic array must first be specified using the
DIM
instruction (usually in
the
INITIAL
task), and the number of elements specified in square brackets
after the variable name. Dynamic arrays are placed in the 8kB of volatile
memory in the
UD70
which limits the maximum size of the array.
Example
DIM myarray%[20]
;Integer array having 20 elements
DIM array2[30]
;Floating-point array having 30 elements
The elements in an array are numbered as follows:
0 to [Number of elements] – 1
From the example of an integer array given above, the first element of
myarray%[]
myarray%[] is as follows:
myarray%[0]
The last element is as follows:
myarray%[19]
Constant
arrays
Constant arrays contain fixed pre-defined values that cannot be changed
by the DPL program when the program is being run. The values of the
constant array are defined in the DPL program by using a special section
called
CONST
. (This section is typed in exactly the same way as a task.)
Only integer values can be defined in a constant array.
The advantage of using a constant array is that the array is placed in the
96kB of memory space in the
UD70
which allows the size of the array to be
limited only by the amount of available program space in the
UD70
, and not
by the size of the 8kB
RAM
. The program space is used to store the
compiled DPL program, constant array data, and (optionally) the
DPL
file itself.
Example
CONST c
_
array% {
100, 1500, 500, 0, –400, –1000
–400, –100, 0
}
This defines an array called c
c
_
array%[]
array%[], which containes nine elements.
Note that the value of each element can be separated by a comma or a
new line.
Содержание UD70
Страница 6: ......
Страница 14: ...UD70 Issue code 70nu2 2 6 Installation...
Страница 42: ...UD70 Issue code 70nu2 4 20 DPL programming...
Страница 98: ...UD70 Issue code 70nu2 7 22 Reference...
Страница 142: ...UD70 Issue code 70nu2 9 6 Diagnostics...