SUBEND [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
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
The SUBEND statement is legal only in a subprogram. It is illegal in the
main program or a multi-line function.
It is good programming practice to end a subprogram with a SUBEND
statement, and use SUBEXIT statements within the subprogram. The SUBEND
statement can appear more than once within a subprogram, and it need not
be the last line. One subprogram ends where the next subunit begins, or
where the program ends.
MPE/iX 5.0 Documentation