Ensuring That A Variable Index Does Not Exceed The Upper Boundary Of An Array - GE PACSystems RXi User Manual

Distributed io controller
Table of Contents

Advertisement

The following do not support array elements with variable indexes:
A variable index cannot be one of the following:
7.1.6

Ensuring that a Variable Index does not Exceed the Upper Boundary of an Array

One-Dimensional Array
Once per scan, execute ARRAY_SIZE_DIM1 to count the number of elements in
1.
the array.
Note:
ARRAY_SIZE_DIM1 places the count value in the variable associated with its output Q.
Before executing an instruction that uses a variable index, compare the value of the index
2.
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
Two-Dimensional Array
GFK-2816F
Indirect references
Reference ID variables (RIVs) and I/O variables when accessed in the Hardware
Configuration
Note:
In logic, RIVs and I/O variables support variable indexes.
STRING variables
A math expression. For example, ABC[GH+1] is not supported.
An indirect reference. For example, W[@XYZ] is not supported.
A bit reference. For example, ABC[DEF.X[3]] is not supported.
Note:
You can use a bit reference on an array element designated by a variable
index. For example, ABC[DEF].X[3] is supported.
An array head. For example, if MNP and QRS are arrays, MNP[QRS] is not
supported, but MNP[QRS[3]] and MNP[QRS[TUV]] are, where TUV is an index
variable.
A negative index. This generates a run-time non-fatal CPU fault.
A value greater than Y, where Y = [number of array elements] - 1. This generates a
run-time non-fatal CPU fault.
The array size of a variable can be changed in a run mode store but it will not be
changed while logic is executing.
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.
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.
August 2015
Chapter 7. CPU Program Data
125

Advertisement

Table of Contents
loading

This manual is also suitable for:

Icrxictl000

Table of Contents