11 INSTRUCTIONS AND FUNCTIONS
Program Example
10 ' This program repeats a calculation while the specified condition holds
20 I=1
30 WHILE I<10
40 PRINT "I=":I
50 I=I+1
60 WEND
70 PRINT "I exceeded 10"
80 END
RUN
I=1
I=2
I=3
I=4
I=5
I=6
I=7
I=8
I=9
I exceeded 10
OK
11 - 401
If the WHILE to WEND instructions are used in combination with the FOR to NEXT
instructions, take precautions so that the inner loop is completely contained
within the outer loop.
(Correct)
REMARK
See the FOR to NEXT instructions and Section 3.6.4.
FOR to TO
WHILE
:
WEND
NEXT
:
' Sets the initial value
:
' Repeats until I exceeds 10
:
' Displays the values of I
:
' Adds 1 to I
:
' Displays the result
MELSEC-Q
(Incorrect)
FOR to TO
WHILE
:
NEXT
WEND
11 - 401