BREAK Statement (MATRIX-END MATRIX command)
The BREAK
statement within a loop structure transfers control immediately
to the statement following the (next) END
LOOP
statement. It is normally placed within a DO IF
structure inside the LOOP
structure to exit the loop when the
specified conditions are met.
Example
LOOP LOCATION = 1, NROW(VEC).
+ DO IF (VEC(LOCATION) = TARGET).
+ BREAK.
+ END IF.
END LOOP.
- This loop searches for the (first) location of a specific value, TARGET, in a vector, VEC.
- The
DO IF
statement checks whether the vector element indexed by LOCATION equals the target. - If so, the
BREAK
statement transfers control out of the loop, leaving LOCATION as the index of TARGET in VEC.