$ECODE

The value of $ECODE is a string that may reflect multiple error conditions. As long as no error has occured, the value of $ECODE is equal to the empty string.

$ECODE contains a list of errors codes for "active" errors - the error conditions which are not yet resolved. If there are no active errors, $ECODE contains the empty string. The value of $ECODE can be SET.

The most recent error in $ECODE appears first, the oldest last. If the error is defined by the M standard, the code starts with an "M", GT.M error codes including those provided by OS services start with "Z", and application defined codes must start with "U". Every code is seperated by a coma (,) and there is always a coma at the begining and at the end of a list. GT.M provided codes are those reported in $ZSTATUS, interpretted by $ZMESSAGE() and recognized as arguments to ZMESSAGE command. When GT.M supplies a standard error code in $ECODE, it also supplies a corresponding 'Z' code.

[Note]

Refer to $Ecode section in Intrinsic Special Variable chapter in this manual, for a detailed description on $ECODE.

Example (setting $ECODE):

	SET $ECODE="" ;sets $ECODE to the empty string
	SET $ECODE=",M20," ;an ANSI M standardized error code
	SET $ECODE=",U14," ;user defined error code
	SET $PIECE($ECODE,",",2)="Z3," ;insert a non-ANSI error code
	SET $PIECE($ECODE,",",$LENGTH($ECODE,",")+1)="An..," ;append	
	

Standard Error processing affects the flow of control in the following manner. Detection of an error causes GOTO implicit sub-routine. When $ECODE="", the implicit subroutine is $ETRAP and QUIT:$QUIT "" QUIT. Otherwise the implicit subroutine is $ETRAP followed by TROLLBACK:$TLEVEL and then QUIT:$QUIT "" QUIT.

The QUIT command behaves in a special fashion while the value of $ECODE is non-empty. If a QUIT command is executed that returns control to a less nested level than the one where the error occurred, and the value of $ECODE is still non-empty, first all normal activity related to the QUIT command occurs (especially the unstacking of NEWed variables) and then the current value of $ETRAP is executed. Note that, if $ETRAP had been NEWed at the current or intervening level, the unstacked value of $ETRAP is executed.

SETting $ECODE to an invalid value is an error. SETting $ECODE to a valid error behaves like detection of error. SETting $ECODE="" does not cause a change in the flow, but effects $STACK(), subsequent $QUITs and errors.

[Note]

To force execution of an error trap or to flag a user-defined error (“U” errors), make the value of $ECODE non-empty:

	SET $ECODE=",U13-User defined error trap,"
	
[Note]

The value of $ECODE provides information about errors that have occurred since the last time it was reset to an empty string. In addition to the information in this variable, more detailed information can be obtained from the intrinsic function $STACK. Refer to the $STACK() topic in the "Functions" chapter in this manual.