EasyManua.ls Logo

Mitsubishi Electric CR750-Q - Page 321

Mitsubishi Electric CR750-Q
730 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
4MELFA-BASIC V
Detailed explanation of command words 4-301
While-WEnd (While End)
[Function]
The program between the While statement and WEnd statement is repeated until the loop conditions are
satisfied.
[Format]
[Terminology]
<Loop Condition> Describe a numeric operation expression. (Refer to Page 166, "4.9 Operators")
[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) ' Repeat the process while the value of numeric variable M1 is
between -5 and +5.
2 M1=M1+1 ' Add 1 to M1.
3 Print# 1, M1 ' Output the M1 value.
4 WEnd ' Return to the While statement (step 1)
5 End ' End the program.
(2) Process of the While-WEnd can be skipped by Break
1 While (M1>=-5) AND (M1<=5) ' Repeat the process while the value of numeric variable M1 is
between -5 and +5.
2 M1=-(M1+1) ' Add 1 to M1, and reverse the sign.
3 M_Out(8)=M1 ' Output the numeric variable M1.
4 If M_In(8)=1 Then Break ' If the input signal 8 is turned on, jump to Step 6.
5 WEnd ' Return to the While statement (step 1)
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.
While[]<Loop Condition>
:
WEnd

Table of Contents

Related product manuals