EXITE
Exit the routine with a specific error
|
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
xcall EXITE(error[, trap_flag])
Arguments
error
The mnemonic or literal of the Synergy DBL error to generate. (n)
trap_flag
(optional) Specifies whether or not the error is trappable, as follows: (n)
0 = Error is not trappable.
1 = Error is trappable. (default)
Discussion
The EXITE subroutine enables you to exit the current external subroutine or function with the specified Synergy DBL error. It also enables you to specify whether that error can be trapped.
If the value of trap_flag is one, the error can be trapped. However, a call must be made to ONERROR prior to the function or subroutine call that contains the EXITE, or the error will not be trapped. If the value is zero, the error cannot be trapped. See the Synergy Errors tab for a complete list of errors.
To generate a nontrappable error, set trap_flag to 0.
In traditional Synergy, a call to EXITE always transfers control to a prior routine and cannot cause a program to stop with a fatal error. In Synergy .NET, any TRY/CATCH in the current or prior routine, or any ONERROR in any prior routine, will catch an exception from EXITE.
Examples
The following hypothetical program checks whether a system is valid. If the system is not valid, it generates a false Synergy DBL error (without disclosing the actual location of the check) so the user will call his or her developer to have “problem” fixed.
Program #1:
main
proc
open(15, o, 'tt:')
xcall chk_sys
stop
endmain
subroutine chk_sys
record
serial, a80
external function
security, ^val
proc
xcall serial(serial)
if (%security(serial) .eq. %FALSE) then
xcall exite($ERR_NOOPEN, 0)
return
endsubroutine
Output:
%DBR-E-NOOPEN, Channel has not been opened
%DBR-I-ATLINE, At line 4 in routine check_system (check_system.dbl)
Program #2:
main
proc
open(15, o, 'tt:')
onerror errlbl
xcall chk_sys
offerror
stop
errlbl,
offerror
writes(15, "Security error")
stop
endmain
subroutine chk_sys
record
serial, a80
external function
security, ^val
proc
xcall serial(serial)
if (%security(serial) .eq. %FALSE) then
xcall exite($ERR_NOOPEN, 1)
return
endsubroutine
Output:
Security error
