6 Programming
6-96
NJ-series CPU Unit Software User’s Manual (W501)
• If the total execution time of the statements in the FOR construct from when the FOR variable is
incremented/decremented from the initial value until it reaches the end value exceeds the task
period, a Task Period Exceeded Error occurs.
• When the FOR Variable Cannot Logically Reach the End Value
Example:
Example:
• When an Overflow or Underflow Occurs Because the FOR Variable Exceeds the End Value
Example:
With the Sysmac Studio version 1.08 or higher, you can specify arithmetic expressions for
<end_value> and <increment/decrement>.
However, the evaluation is performed for <end_value> or <increment/decrement> only before the
execution of FOR loop operation. The values of <end_value> and <increment/decrement> do
not change after the FOR loop operation is started.
For example, in the following case, the value of <end_value> is 10 and <increment/decrement>
is 3. Even after the FOR loop operation is started and the values of variable A and C are
changed, the value of <end_value> is still 10 and <increment/decrement> is still 3.
If an arithmetic expressions is specified for <end_value> or <increment/decrement> on the Sys-
mac Studio version 1.07 or lower, a building error will occur.
Data Types That You Can Use in FOR Constructs
FOR i := 0 TO 254 BY 2 DO
INTArray[i] := i;
END_FOR;
A := INT#1;
B := INT#2;
C := INT#10;
FOR i := 0 TO C BY A+B DO
INTArray[i] := i;
A := B + i;
C := C + i;
END_FOR;
Classification Data type
<initial_value>, <end_value>,
and <increment/decrement>*
Basic data types
Boolean, bit string, real, duration, date, time
of day, date and time, or text string data
Not supported.
Integers Supported.
Data type specifica-
tions
Array specifications
Arrays Not supported.
Elements
Supported for integers and enu-
merations only.
FOR i := 0 TO 100 BY 1 DO
intArray[i] := i;
i := INT#50;
END_FOR;
An infinite loop occurs and results in a Task
Period Exceeded Error.
FOR i := 0 TO 100 BY 0 DO
;
END_FOR;
An infinite loop occurs and results in a Task
Period Exceeded Error.