ProvideX V8.20 > Language Reference > 2. Directives
123
EXIT Directive
             Terminate Subprogram and Return
Format
EXIT [ERR | err_val ]
Where:
err_val
Numeric expression whose value will be returned as an error status to
the program initiating the subprogram (e.g., via a CALL directive).
Restriction: You can only use this directive in subprograms. Otherwise, ProvideX
returns Error #37: Directive can only execute in subprogram.
Description
Use the EXIT directive in a subprogram to terminate the subprogram and return
control to the initiating program.
You can have the subprogram return an error code value to the calling program by using
EXIT ERR or by specifying the error value following the EXIT directive. Use an integer
from 0 to 32767 for the error value. To have the calling program process an error value
other than zero, use the ERR= option in the CALL directive (or use SETERR numeric
expression). If the value is 0 zero, ProvideX does not retry processing.
When you use EXIT in a compound statement, it must be the final directive:
9000 PRINT "Subroutine done"; EXIT
See Also
CALL Transfer to Subprogram, p.40
PERFORM Call Subprogram, Pass Variables, p.241
Called Procedures, User's Guide.
Examples
10000
! In subprogram "SUBPR"
10005
TEST_EXIT:
10010
SETERR UNKNOWN_ERROR
10020
ENTER TEST$
10030
LET T=NUM(TEST$(5,6))
10040
EXIT
10050
UNKNOWN_ERROR:
10060
EXIT ERR