A-Shell provides several different EXIT statements as shown below.
u EXIT
The EXIT statement may be used within a control structure (FOR...NEXT, DO/WHILE/UNTIL, SWITCH, FOREACH) to exit the structure, proceeding to the next statement following the end of the structure. For example:
DO WHILE A < B
...
IF TIME > 82800 EXIT ! exit loop after 11 PM
...
LOOP
|
u EXITPROGRAM
Written February 2024
EXITPROGRAM
The EXITPROGRAM statement causes an exit directly from a function or procedure, regardless of how nested, to a special label $EXITPROGRAM in the main program, or to the END if the $EXITPROGRAM label doesn't exist. Although this is effectively an unstructured GOTO, it handles the stack cleanup and provides an solution to the problem of how percolate the desire for a program exit up from a nested function to the top level.
The EXITPROGRAM token can also be used in a RESUME statement in place of EXITFUNCTION, EXITPROCEDURE, or $EXIT...
RESUME EXITPROGRAM {WITH_ERROR {N}}
RESUME $EXITPROGRAM {WITH_ERROR {N}} ! (equivalent)
|
u EXITFUNCTION
Written February 2024
EXITFUNCTION
EXITFUNCTION is used exclusively within functions to exit the routine and return to the caller. Note however that if the function contains an $EXIT label, then EXITFUNCTION becomes equivalent to GOTO $EXIT, allowing for some final cleanup code to be executed and even opening the possibility of canceling the exit and jumping to some other place within the current function.
See Also
|
u EXITPROCEDURE
Written February 2024
EXITPROCEDURE
EXITPROCEDURE is used exclusively within procedures to exit the procedure and return to the caller. Note however that if the procedure contains an $EXIT label, then EXITPROCEDURE becomes equivalent to GOTO $EXIT, allowing for some final cleanup code to be executed and even opening the possibility of canceling the exit and jumping to some other place within the current procedure.
See Also
|