4MELFA-BASIC IV
Detailed explanation of command words
4-158
CallP (Call P)
[Function]
This instruction executes the specified program (by calling the program in a manner similar to using GoSub
to call a subroutine). The execution returns to the main program when the End instruction or the final step in
the sub program is reached.
[Format]
[Terminology]
<Program name>
Designate the program name with a character string constant or character string variable.
For the standards for program names, please refer to
<Argument>
Designate the variable to be transferred to the program when the program is called. Up
to 16 variables can be transferred.
[Reference Program]
(1) When passing the argument to the program to call.
Main program
1 M1=0
2 CallP "10" ,M1,P1,P2
3 M1=1
4 CallP "10" ,M1,P1,P2
:
10 CallP "10", M2,P3,P4
:
15 End
"100" sub program side
100 FPrm M01, P01,P02
101 If M01<>0 Then GoTo *LBL1
102 Mov P01
103 *LBL1
104 Mvs P02
105 End
'Return to the main program at this point.
* When step 2 and 4 of the main program are executed, M1, P1 and P2 are set in M01, P01 and P02 of
the sub program, respectively. When step 100 of the main program is executed, M2, P3 and P4 are set in
M01, P01 and P02 of the sub program, respectively.
(2) When not passing the argument to the program to call.
Main program
1 Mov P1
2 CallP "20"
3 Mov P2
4 CallP "20"
5 End
"200" sub program side
201 Mov P1
'P1 of the sub program differs from P1 of the main program.
202 Mvs P002
203 M_Out(17)=1
204 End
'Return to the main program at this point.
CallP[] "<Program name> " [, <Argument> [, <Argument>