11 - 71 11 - 71
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
If the nested loops have the same end point, multiple variable names can be described
following one NEXT instruction.
However, list variable names in the order starting from the one that corresponds to the
closest FOR instruction.
FOR I=0 TO 10
FOR J=0 TO 10
to
NEXT J, I
• A “NEXT without FOR” error occurs if the NEXT instruction without the corresponding FOR
instruction is detected.
Program Example
10 ' Makes a multiplication table
30 FOR I=1 TO 9
:
' Repeats with I=1 to 9
40 FOR J=1 TO 9
:
' Repeats with I=1 to 9
50 PRINT USING "####";I*J;
:
' Displays the value of I*J
60 NEXT J
70 PRINT
:
' New line
80 NEXT I
90 END
RUN
1
2
3
4
5
6
7
8
9
2
4
6
8
10
12
14
16
18
3
6
9
12
15
18
21
24
27
4
8
12
16
20
24
28
32
36
5
10
15
20
25
30
35
40
45
6
12
18
24
30
36
42
48
54
7
14
21
28
35
42
49
56
63
8
16
24
32
40
48
56
64
72
9
18
27
36
45
54
63
72
81
OK
REMARK
See the ERASE and WHILE to WEND instructions, and Section 3.6.3.