SUBEXIT [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
SUBEXIT
The SUBEXIT statement returns control to the program unit that called the
subprogram. SUBEXIT can be used to exit a subprogram prior to execution
of the SUBEND statement. Like the SUBEND statement, the SUBEXIT
statement returns control to the statement following the CALL statement
that called the subprogram. Although the SUBEXIT statement can be
entered as either SUBEXIT or SUB EXIT, HP Business BASIC/XL will always
enter it as SUBEXIT.
Syntax
{SUBEXIT }
{SUB EXIT}
The SUBEXIT statement is optional. If a program does not contain one,
execution of the SUBEND statement returns control to the calling program
unit.
A program can contain more than one SUBEXIT statement. Usually, a
SUBEXIT statement is executed conditionally.
Example
10 READ A,B
20 CALL Sub(A,B) !Control transfers to line 100
30 PRINT "DONE"
80 DATA 1,2
99 END
100 SUB Sub(X,Y) !Start of Subprogram
105 INTEGER Z
110 IF X<0 THEN SUBEXIT !If X < 0, control returns to line 30
120 LET Z=X+Y
130 IF Z<0 THEN SUBEXIT !If Z < 0, control returns to line 30
140 PRINT Z
999 SUB END
A SUBEXIT statement is legal only in a subprogram. SUBEXIT is illegal in
a main program or multi-line function.
MPE/iX 5.0 Documentation