Mitsubishi MELFA CR1D Instruction Manual page 245

Table of Contents

Advertisement

On ... GoSub (ON Go Subroutine)
[Function]
Calls up the subroutine at the step label corresponding to the value.
[Format]
On[]<Terminology>[]GoSub[][<Expression>] [, [<Call Destination>]] ...
[Terminology]
<Terminology>
<Call Destination> Describe the step label No. The maximum number is 32.
[Reference Program]
Sets the value equivalent to three bits of input signal 16 in M1, and branches according to the value of M1
(1 through 7).
(Calls line 1000 if M1 is 1, label LSUB if M1 is 2, line 2000 if M1 is 3, 4 or 5, and label L67 if M1 is 6 or 7.)
1 M1 = M_Inb(16) AND &H7
2 On M1 GoSub *L1,*LSUB,*L2,*L2,*L2,*L67,*L67
:
10 *L1
11 ' Describes processing when M1=1.
12 '
13 Return
20 *LSUB
21
22 Return
30 *L67
31 ' Describes processing when M1=6 or M1=7.
32 Return
40 *L2
41 ' Describes processing when M1=3, M1=4, or M1=5.
42 '
43 Return
[Explanation]
(1) The value of <Expression> determines which step label subroutine to call.
For example, if the value of <Expression> is 2, the step label described for the second value is called.
(2) If the value of <expression> is larger than the number of <destinations called up>, the program control
jumps to the next step. For example, the program control jumps to the next step if the value of <expres-
sion> is 5 and there are only three <destinations called up>.
(3) When a step No. or abel that is called up does not exist, or when there are two definitions, an error will
occur.
(4) Make sure to return from a subroutine using the Return instruction. An error occurs if the GoTo instruc-
tion is used to return, because the free memory available for control structure (stack memory)
decreases and eventually becomes insufficient.
Value of <Expression>
Real number
When 0, or when the value exceeds the num-
ber of step labels
Negative number or 32767 is exceeded
Designate the step label on the step to branch to with a numeric operation expression.
' Be sure to return by using Return.
' Describes processing when M1=2.
' Be sure to return by using Return.
' Be sure to return by using Return.
' Be sure to return by using Return.
Process <Control>
Value is converted to an integer by rounding it off,
and then branching is executed.
Control proceeds to the next step
Execution error
Detailed explanation of command words 4-232
4MELFA-BASIC IV

Advertisement

Table of Contents
loading

This manual is also suitable for:

Melfa cr2dMelfa cr3d

Table of Contents