2-81
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Sequence Control Instructions
2
BREAK
BREAK
The BREAK instruction is used to cancel repeat processing from the lowest level FOR instruction to the
NEXT instruction.
None
The BREAK (EXIT) instruction cancels the repeat processing from the lowest level FOR instruction to
the NEXT instruction (the END_FOR instruction for ST). It moves processing to the next instruction
after the NEXT instruction. The processing between the BREAK instruction and the NEXT instruction
(or the EXIT instruction in ST) will not be executed.
The following figure shows a programming example. When the FOR loop is executed, the value of vari-
able A is checked each time. If the value of variable A is TRUE, the repeat processing is ended immedi-
ately. In this example, the Out instruction after the BREAK instruction is not executed, and the value of
variable C is retained. (In ST, the EXIT instruction is used instead of the BREAK instruction.)
Instruction Name FB/FUN Graphic expression ST expression
BREAK Break Loop FUN FOR Index:=0 TO 9 BY 1
DO
IF Error[index] THEN
EXIT*;
END_IF
END_FOR;
* In ST, use EXIT instead of
BREAK for the BREAK
LOOP instruction. The
meaning is the same.
Variables
Function
BREAK
EN ENO
FOR position:=INT#0 TO INT#10 BY INT#1 DO
IF (A=TRUE) THEN
EXIT;
END_IF;
C:=B;
END_FOR;
LD ST
A
INT#0
INT#10
INT#1
position
FOR
EN ENO
InitVal Index
EndVal
StepVal
NEXT
EN ENO
BREAK
EN ENO
B C