Mitsubishi Electric CR750-Q Instruction Manual page 264

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

Advertisement

4MELFA-BASIC V
If...Then...Else...EndIf (If Then Else)
[Function]
A process is selected and executed according to the results of an expression.
[Format]
If[]<Expression>[]Then[]<Process>[][Else <Process>]
.
If[]<Expression>[]Then
<Process>
<Process>
Break
:
[Else
<Process>
<Process>
Break
: ]
EndIf
[Terminology]
<Expression>
<Process>
[Reference Program]
1 If M1>10 Then *L1
11 If M1>10 Then GoTo *L2 Else GoTo *L3
:
19 *L1
20 M1=10
21 Mov P1
22 GoTo *LC
23 *L2
24 M1=-10
25 Mov P2
26 GoTo *LC
[Explanation]
(1) The If .. Then .. Else .. statements should be contained in one step.
(2) It is allowed to split an If .. Then .. Else .. EndIf block over several steps.
(3) Else can be omitted.
(4) Make sure to include the EndIf statement in the If .. Then .. Else .. EndIf block.
(5) If the GoTo instruction is used to jump out from inside an If .. Then .. Else .. EndIf block, an error will
occur when the memory for control structure (stack memory) becomes insufficient.
(6) For If .. Then .. Else .. EndIf, it is possible to describe If .. Then .. Else .. EndIf inside Then or Else. (UP to
eight levels of nesting is allowed.)
(7) GoTo following Then or Else may be omitted.
Example) If M1 > 10 Then *L200 Else *L300
Also, only when Then is followed by GoTo, either one of Then or GoTo may be omitted. Else
cannot be omitted.
Example) If M1 > 10 Then GoTo *L200 (The program at left can be rewritten as shown below.)
(8) In the Then or the Else, it can escape to the next step of EndIf by Break. That is, process of If Then EndIf
can be skipped.
4-244 Detailed explanation of command words
Describe the expression targeted for comparison as a comparison operation expression
or logic operation expression.
Describe the process following Then for when the comparison results are true, and the
process following Else for when the comparison results are false.
→ If M1 > 10 Then *L200
→ If M1 > 10 GoTo *L200
' When M1 is larger than 10, jump to the step
*L1.
' If M1 is larger than 10, it jumps to step *L2; if
smaller than 10, it jumps to label *L3.
The "GoTo" after" Then" or "Else" can be
omitted.

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cr750Cr751-qCr751-dCr760-dCr760-qCr750-d

Table of Contents