2 Instruction Descriptions
2-390
NJ-series Instructions Reference Manual (W502)
If the value of CurIndex is set to 0 before the instruction is executed, the values in Buf[0] to Buf[BufSize
−
1] are set to 0 and the current value of In is stored again in Buf[0].
The value of CurIndex changes to 1 and the value of Q changes to FALSE.
If you change the value of BufSize and execute the instruction, operation is performed with the new
value of BufSize and the current value of CurIndex.
• Use the same data type for In and the elements of Buf[].
• Use a Buf[] array that is at least as large as the value of BufSize.
• Even if the calculation result exceeds the valid range of Out, an error will not occur. The value of Out
will be an illegal value.
• If the value of BufSize is 0, the values of Out and CurIndex change to 0. The value of Q changes to
TRUE.
• If you change the value of BufSize, always set the value of CurIndex to 0 and initialize the stored val-
ues.
• An error occurs in the following cases. ENO will be FALSE, and Out will not change.
• In and Buf[] are different data types.
• The value of BufSize is outside of the valid range.
• The value of BufSize exceeds the size of the Buf[] array.
• Buf[] is not an integer array.
• An array without a subscript is passed to Buf[].
Initializing the Stored Values
Changing the Value of BufSize
Precautions for Correct Use
CurIndex=def
In=abc
Status before Instruction Execution BufSize=3
Out=jkl
Q=mno
CurIndex is equal to or higher than BufSize,
so the value of CurIndex returns to 1.
Not included in the average.
CurIndex=def
Instruction Execution after Setting BufSize to 2
Out=jkl
Q=mno
Average of Buf[0] and Buf[1]
CurIndex=def
CurIndex is equal to or higher than BufSize,
so the value of In is stored in Buf[1].
TRUE because the number of numbers
stored has reached BufSize.
2
4567
2345
3456
3456
TRUE
2
5678
5678
2345
3456
4011
TRUE
1
Buf[0]=ghi[1]
Buf[1]=ghi[2]
Buf[2]=ghi[3]
Buf[0]=ghi[1]
Buf[1]=ghi[2]
Buf[2]=ghi[3]