Mitsubishi MELFA CR1D Instruction Manual page 267

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]
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
[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.
Describe a numeric operation expression. (Refer to the syntax diagram)
' 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 M1 value.
' Return to the While statement (step 1)
' End the program.
Detailed explanation of command words 4-254
4MELFA-BASIC IV

Advertisement

Table of Contents
loading

This manual is also suitable for:

Melfa cr2dMelfa cr3d

Table of Contents