4-243
Detailed explanation of command words
4MELFA-BASIC IV
Return (Return)
[Function]
(1) When returning from a normal subroutine returns to the next step after the GoSub.
(2) When returning from an interrupt processing subroutine, returns either to the step where the interrupt
was generated, or to the next step.
[Format]
(1) When returning from a normal subroutine:
(2) When returning from an interrupt processing subroutine:
[Terminology]
<Return Designation No.> Designate the step number where control will return to after an interrupt has been
generated and processed.
0 ... Return control to the line where the interrupt was generated.
1 ... Return control to the next line after the line where the interrupt was issued.
[Reference Program]
(1) The example of Return from the usual subroutine .
1 ' ***MAIN PROGRAM***
2 GoSub *SUB_INIT
' Subroutine jumps to label SUB_INIT.
3 Mov P1
:
100 ' ***SUB INIT***
' Subroutine
11 *SUB_INIT
12 PSTART=P1
13 M100=123
14 Return
' Returns to the step immediately following the step where the subrou-
tine was called from.
(2) The example of Return from the subroutine for interruption processing. Calls the subroutine on step 10
when the input signal of general-purpose input signal number 17 is turned on.
1 Def Act 1,M_In(17)=1 GoSub *SUB1 ' Definition of interrupt of Act 1.
2 Act 1=1
' Enable the Act 1.
:
10 *SUB1
' The subroutine for interrupt of Act 1.
11 Act 1=0
' Disable the interrupt.
12 M_Timer(1)=0
' Set the timer to zero.
13 Mov P2
' Move to P2.
14 Wait M_In(17)=0
' Wait until the input signal 17 turns off.
15 Act 1=1
' Set up interrupt again.
16 Return 0
' Returns control to the interrupted step.
Return
Return <Return Designation No.>