Mitsubishi Electric CR750-Q Instruction Manual page 321

Cr750/cr751/cr760 series
Hide thumbs Also See for CR750-Q:
Table of Contents

Advertisement

While-WEnd (While End)
[Function]
The program between the While statement and WEnd statement is repeated until the loop conditions are
satisfied.
[Format]
While[]<Loop Condition>
:
WEnd
[Terminology]
<Loop Condition>
[Reference Program]
(1) Repeat the process while the numeric variable M1 value is between -5 and +5, and transfer control to
step after WEnd statement if range is exceeded.
1 While (M1>=-5) AND (M1<=5)
2 M1=M1+1
3 Print# 1, M1
4 WEnd
5 End
(2) Process of the While-WEnd can be skipped by Break
1 While (M1>=-5) AND (M1<=5)
2 M1=-(M1+1)
3 M_Out(8)=M1
4 If M_In(8)=1 Then Break
5 WEnd
6 If M_BrkCq=1 Then Hlt
[Explanation]
(1) The program between the While statement and WEnd statement is repeated.
(2) If the result of <Expression> is true (not 0), the control moves to the step following the While statement
and the process is repeated.
(3) If the result of <Expression> is false (is 0), then the control moves to the step following the WEnd state-
ment.
(4) If a GoTo instruction forces the program to jump out from between a While statement and a WEnd state-
ment, the free memory available for control structure (stack memory) decreases. Thus, if a program is
executed continuously, an error will eventually occur. Write a program in such a way that the loop exits
when the condition of the While statement is met.
(5) In the While, it can escape to the next step of the WEnd by Break. That is, process of the While-WEnd
can be skipped.
Describe a numeric operation expression. (Refer to
' Repeat the process while the value of numeric variable M1 is
between -5 and +5.
' Add 1 to M1.
' Output the M1 value.
' Return to the While statement (step 1)
' End the program.
' Repeat the process while the value of numeric variable M1 is
between -5 and +5.
' Add 1 to M1, and reverse the sign.
' Output the numeric variable M1.
' If the input signal 8 is turned on, jump to Step 6.
' Return to the While statement (step 1)
Page 166, "4.9
Detailed explanation of command words 4-301
4MELFA-BASIC V
Operators")

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cr750Cr751-qCr751-dCr760-dCr760-qCr750-d

Table of Contents