NET/MASTER Network Control Language (NCL) Reference Manual
ON
Core Statements
106126 Tandem Computers Incorporated 2–41
Examples
The following procedure named ONPROC has an error in it. The ON block (error
handler) displays information that can help you find the error:
ONPROC: PROCEDURE
ON ERROR DO
WRITE DATA="AN ERROR OCCURRED IN KEYWORD",
&SYS.ERROR.KEYWORD,
"of STATEMENT" &SYS.ERROR.STMT_NAME,
"AT POSITION " &SYS.ERROR.STMT,
"IN LINE " &SYS.ERROR.LINE
RESUME
END
&COL=OOPS
WRITE COLOR=&COL DATA="THIS IS TEST TEXT"
END ONPROC
The previous procedure displays:
&SYS.ERROR.KEYWORD, which tells you which keyword in the statement is
wrong. In the present case, it is the color option represented by the variable
&COL.
&SYS.ERROR.STMT_NAME, which tells you which statement contains the error—
the WRITE statement.
&SYS.ERROR.STMT, which tells you the statement number within the line that
contains the error.
&SYS.ERROR.LINE, tells you the Tedit line number in the source file that contains
the error.
In the following example, an ON block is coded to specifically intercept or trap
variable assignment errors:
ONPROC: PROCEDURE
ON VARIABLE_ERROR DO
WRITE DATA="ERROR IN TRYING TO ASSIGN A VARIABLE TO",
&SYS.ERROR.NAME
RESUME
END
&A=10
&B =&SYS.&A
END ONPROC
In the previous example, when a variable assignment error occurs, the error handler
displays the name of the variable causing the error and then ignores the error by using
the RESUME statement.