SET ERC
Set Error Condition Variable
This directive specifies a user-defined value for the ERC system variable. This variable will contain the value if an error occurred during processing; if no error occurred ERC will contain 0, its initial value.
Syntax
Section titled “Syntax”SET ERC numeric-valuenumeric-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 of processing errors. The ERR=line-ref 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 the ERC system variable can help you write Thoroughbred Basic programs that meet structured programming standards. You can use ERC and ERR in the same program but when ERC is set all ERR= branches are ignored.
To specify a user-defined error code, use SET ERC numeric value. To determine whether an error occurred, you can use ERC in an IF statement.
The ERC system variable is initialized to 0. To reset ERC to 0 you can use the SET ERC 0 directive. To isolate error conditions within chunks of code you can use SET ERC numeric-value closely followed by SET ERC 0.
Examples
Section titled “Examples”SET ERC 20;A$="ABC";A=NUM(A$);PRINT ERC;SET ERC 0prints 20 because an error occurred. The A$ string does not contain numerals. For example, if A$ had contained 123, PRINT ERC would have printed 0, which means that no error occurred.
See also
Section titled “See also”SETERR and CLEAR ERC directives
ERR function
ERC and ERR system variables
From the Thoroughbred Basic Language Reference, Volume III: R–Z, version 8.9.1. Open this page in the PDF