HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)
4- 140
calling program unit.
#
fnum
A file designator.
fnum
is a
positive short integer greater
than zero. The file
designated by the actual
parameter
file designator
is
referenced by #
fnum
within the
subprogram.
Examples
SUBPROGRAM Sub1 (A(*), B$(*,*), INTEGER X,Y, P$, C,D, #15)
SUB Sub2 (A(), B$(*), INTEGER X,Y P$, C,D, #15)
The above statements define the beginning of subprograms named Sub1 and
Sub2 that have the following formal parameters:
Parameter Type
A Array of default numeric type.
B$ A 2-dimensional string array variable in Sub1.
A 1-dimensional string array variable in Sub2.
X and Y Integer variables.
P$ String variable.
C and D Variables of default numeric type.
#15 File designator.
NOTE If a program has more than one subprogram with the same name, all
calls refer to the first one; that is, the one with the
lowest-numbered SUBPROGRAM statement. The others cannot be called.
SUBEND
The SUBEND statement ends a subprogram. Like the SUBPROGRAM statement,
which begins a subprogram, the SUBEND statement is not executable. It
returns control to the program unit that called the subprogram.
Specifically, the statement returns control to the line following the
CALL statement that originally called the subprogram. Although the
SUBEND statement can be input as SUBEND or SUB END, HP Business BASIC/XL
will always list it as SUBEND.
Syntax
{SUBEND }
{SUB END}
If a subprogram does not end with a SUBEND statement; that is, if the
SUBEND statement is accidentally omitted, SUBEND is implied. Control
does not pass to the following subunit.
Example
10 CALL Sub1(L,M,N) !Call Sub1 from main program
99 END !End main program
100 SUB Sub1 (A,B,C) !Begin Sub1
110 A=B+C
120 CALL Sub2(A,B,C) !Call Sub2 from Sub1
130 SUBEND !End Sub1
140 !
200 SUB Sub2(X,Y,Z) !Begin Sub2
210 X=Y*Z
220 SUBEND !End Sub2