Chapter 3. Program Data
36
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
GFK-2950C
Ensuring that a Variable Index does not Exceed the Upper Boundary of an Array
One-Dimensional Array
1.
Once per scan, execute ARRAY_SIZE_DIM1 to count the number of elements in the array.
Note:
The array size of a variable can be changed in a RUN Mode Store but it will not be changed
while logic is executing.
ARRAY_SIZE_DIM1 places the count value in the variable associated with its output Q.
2.
Before executing an instruction that uses a variable index, compare the value of the index variable
with the number of elements in the array.
Tip:
In LD, use a RANGE instruction.
Notes
Checking before executing each instruction that uses an indexed variable is recommended in
case logic has modified the index value beyond the array size or in case the array size has
been reduced before the scan to less than the value of an index variable that has not been
reduced accordingly since.
Valid range of an index variable: 0 through (n
–
1), where n is the number of array elements.
Array indexes are zero-based.
Two-Dimensional Array
▪
Execute both ARRAY_SIZE_DIM1 and ARRAY_SIZE_DIM2 to count the number of elements in
respectively the first and second dimensions of the array.
Summary of Contents for PACSystems RX7i
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451...