ERC
Error Condition Variable
This system variable returns the number of the user-defined error condition that last occurred during program processing.
Syntax
Section titled “Syntax”ERC[=numeric-value]numeric-value is any valid negative or positive whole number.
Remarks
Section titled “Remarks”The ERC system variable, and the SET ERC and CLEAR ERC directives provide an alternate way to process errors. The ERR= option common to many Thoroughbred Basic directives, the ERR system variable, the ERR function, and the SETERR directive force a branch to a line number. Errors processed through ERC do not require you to change program flow. Using ERC can help you write Thoroughbred Basic programs that meet structured programming standards. You can, however, use ERC and ERR in the same program.
To specify a user-defined error code, use ERC=numeric value. ERC will contain the value only if an error occurs. To test for the error condition, you can use ERC in an IF statement.
This system variable is initialized to 0. To reset ERC to 0 you can use the CLEAR ERC directive. To isolate sections of code in which errors may occur, you specify a value for ERC closely followed by the CLEAR ERC directive.
Examples
Section titled “Examples”OPEN(1, ERC=5) "NOFILE"IF ERC=5 PRINT ERCCLEAR ERCIf NOFILE does not exist, the output is 5. If NOFILE exists, there is no output, which means that no error occurred.
See also
Section titled “See also”SET ERC, CLEAR ERC directives, ERR function, and ERR system variable
From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF