GE PACSystems RX7i Cpu Programmer's Reference Manual page 157

Hide thumbs Also See for PACSystems RX7i:
Table of Contents

Advertisement

Chapter 4. Ladder Diagram (LD) Programming
Example - FOR_LOOP that Iterates Through Dimension 1 of an Array
To use a FOR_LOOP to access array elements by means of a variable index, you must ensure that the
FOR_LOOP does not iterate beyond the last element of the array.
In the following logic, MOVE_DINT initializes the variable D1_temp to 0. ARRAY_SIZE_DIM1 counts
the number of elements of a one-dimensional array named D1_Array and outputs the result to
output Q. Because the index of the first element of an array is zero, the loop must iterate (Q - 1)
times. SUB_DINT performs the subtraction and the result is converted to an INT value and assigned
to variable D1_size.
In the following rungs, the FOR_LOOP executes when D1ON is set to On. The variable index D1_Index
increments by 1 from 0 through D1_size, the value calculated by ARRAY_SIZE_DIM1 and SUB_DINT. In
each loop, the value of D1_temp is assigned to the element D1_Array[D1_Index] and D1_temp is
increased by 1.
You can use a FOR_LOOP to iterate through an array's second dimension in a method similar to this
example. You can also use nested FOR_LOOPs to ensure that operations on elements using two
variable indexes each do not exceed their array dimension. For additional examples, refer to the
online help.
142
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
GFK-2950C

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pacsystems rx3iPacsystems rsti-ep

Table of Contents