EasyManua.ls Logo

Omron NJ Series - Page 281

Omron NJ Series
668 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
6 Programming
6-94
NJ-series CPU Unit Software User’s Manual (W501)
Process Flow Diagram:
Application:
Use this construct when you know in advance how many times you want to repeat a process.
This type of repeat construct is particularly effective to specify each element of an array variable
based on the value of a FOR variable.
Description:
A decision is made based on the evaluation of <initial_value>, <end_value>, and <increment/decre-
ment>.
When <FOR_variable> is <initial_value>, <statement> is executed.
After execution, the value of <increment/decrement> is added to <FOR_variable> and <statement>
is executed again if <FOR_variable> is less than the value of the <end_value>.
After execution, the value of <increment/decrement> is added to <FOR_variable> and <statement>
is executed again if <FOR_variable> is less than the value of the <end_value>.
This process is repeated.
The loop ends when <FOR_variable> > <end_value>.
If <increment/decrement> is negative, the directions of the comparison symbols in the above state-
ments are reversed.
Precautions:
If the FOR variable is signed, <increment/decrement> can be a negative number.
FOR must always be used together with END_FOR.
The FOR variable becomes the end value plus increment/decrement after execution of the pro-
cess is completed for the end value. This ends the FOR construct.
Example: When the FOR construct is completed in the following ST statements, the value of i is
101.
FOR i:=0 TO 100 DO
X[i]:=0;
END_FOR;
// Here, i is 101.
FOR variable = Initial value
TRUE
Statement
FALSE
Repeated
End
FOR variable >
end value?
FOR variable +
Increment/decrement value

Table of Contents

Other manuals for Omron NJ Series

Related product manuals