NET/MASTER Network Control Language (NCL) Programmer's Guide

Writing an Error Handler
Run-Time Error Handling
7–12 106160 Tandem Computers Incorporated
The following screen shows the results of executing the procedure:
(14:11) --------------------- OPERATOR CONTROL SERVICES ----------------------
START ZEX0706N
Divide 100 by what number?
Please enter ZZZZZ or a number
|NM1060 PROCEDURE ZEX0706N NCLID 2049 PAUSED
GO ID=2049 17
100 divided by 17 is 5.88235294117647
Divide 100 by what number?
Please enter ZZZZZ or a number
|NM1060 PROCEDURE ZEX0706N NCLID 2049 PAUSED
GO ID=2049 ABC
ABC is an invalid denominator
Please try again
Divide 100 by what number?
Please enter ZZZZZ or a number
|NM1060 PROCEDURE ZEX0706N NCLID 2049 PAUSED
GO ID=2049 ZZZZZ
You have entered ZZZZZ
Normal termination
NNM1005 START ZEX0706N PROCESSING COMPLETE. NCLID 002049
_____________________________________________________________________________
---------- ------------------ NonStop NET/MASTER D30 ---------------- --------
M=>
The values entered are 17 (correctly), ABC (incorrectly), and ZZZZZ, which terminates
execution of the NCL process.
Using the RETRY Statement to Recover From an Error
The RETRY statement leaves an error handler and continues execution from the
statement raising the error condition—it retries the statement. The following example
uses a DO loop to pause an NCL process, obtain a number that is used as the
denominator to divide 100, and display the results of the division:
zex0707n: PROCEDURE
/* Using RETRY to recover from an error */
ON ERROR DO
SAY &1" is an invalid denominator"
SAY "Substituting a denominator of 1"
&1 = 1
RETRY
END
DO UNTIL &1 = ZZZZZ
SAY "Divide 100 by what number?"
SAY "Please enter ZZZZZ or a number"
CMDLINE "GO ID="&SYS.NCLID _
PAUSE VARS=&1
IF &1 = ZZZZZ THEN ITERATE
SAY "100 divided by "&1" is "100/&1
END /*do*/
SAY You have entered ZZZZZ
SAY Normal termination
END zex0707n