IB Statements/excp
From CometWiki
Exception path
Parameter: EXCP=statement-label
Discussion: This parameter is used in input/output statements to specify the statement-label where program control is transferred if a runtime exception occurs.
If a runtime exception occurs, the program will branch to the statement-label specified. At that statement label, the program may contain statements to inquire into the nature of the exception.
For more information, see Exception Handling.
Also see EXCPSUB=.
Example:
OPEN (1) "CUSTFILE", EXCP=LABEL1 ! OPEN FILE . INPUT (0) CUSTNUM$ ! ENTER CUST. NO. READ (1,1000) KEY=CUSTNUM$, EXCP=LABEL2 ! READ RECORD . LABEL1: IF EXCP = 11 THEN ... ! FILE NOT FOUND EXCEPTION . LABEL2: IF EXCP = 32 THEN ... ! KEY NOT FOUND EXCEPTION IF EXCP = 33 THEN ... ! RECORD LOCKED EXCEPTION
In this example, the OPEN statement attempts to open a file named "CUSTFILE". If an exception occurs, the program branches to LABEL1:, where the system variable named EXCP is interrogated. If the EXCP variable equals 11, Comet was not able to find the data file (most likely because such a file name did not exist).
The READ statement attempts to read a record from the customer file with a key value equal to the input value (i.e., the customer number). If an exception occurs, the program branches to LABEL2:, where the system variable named EXCP is interrogated.
If EXCP equals 32, the specified customer number key was not found in the file.
If EXCP equals 33, the specified customer number key was locked (extracted) by another user.
See system variables and EXCP for more information.