|
|
Accessing Files Programmer's Guide: HP 3000 MPE/iX Computer Systems > Chapter 14 Getting File InformationDisplaying File Error Information |
|
Several file system intrinsics are designed specifically for handling errors. If an I/O error occurs, most file system intrinsics return a condition code indicating this.
The FCHECK intrinsic returns an error code that indicates the nature of a file system I/O error. A table of error codes appears in the MPE/iX Intrinsics Reference Manual (32650-90028), or you can use FERRMSG (described below) to display an error message. FCHECK has five optional parameters. The filenum parameter indicates the file for which error information is to be returned. If you set this parameter to zero, FCHECK assumes you want information about the last failed FOPEN call. The error code is returned in the errorcode parameter.
Three other parameters give additional information about file system errors. The tlog parameter returns the number of half-words read or written if an I/O error occurs. The blknum parameter gives the logical record count for a spool file, or the physical record count for any other type of file. The numrecs parameter returns the number of logical records in the bad block. You must use this intrinsic prior to calling FERRMSG, since the error code returned by FCHECK is used as a parameter in the call to FERRMSG. This intrinsic is used following a call to FCHECK, to return an error message explaining the nature of a file system error. It has three required parameters: errorcode is the error number returned by FCHECK, msgbuf returns the error message, and msglgth returns the length of the error message returned in msgbuf. This example shows a call to FCLOSE. If this returns a CCL condition, a call to FCHECK requests the error code; then FERRMSG returns the error message associated with this code:
If the FCHECK code has no assigned meaning, the following message is returned:
This intrinsic prints a file information display on the job or session list device, $STDLIST. The information shown depends upon whether or not a file is opened when the error occurs. For files not yet opened, or for which the FOPEN intrinsic fails, the display shown in Figure 14-1. Example 14-1. File Information Display, Unopened File
The lines in this display show the following information:
For files that are open when a CCG (EOF error) or CCL (irrecoverable file error) was returned, the file information display appears as shown in example 14-2. Example 14-2. File Information Display, Opened File
The lines on the above display show the information listed in Table 14-3 “PRINTFILEINFO Information”. Table 14-3 PRINTFILEINFO Information
Error checking intrinsics can be used throughout a program every time that there is an intrinsic call. Instead of repeating a call to PRINTFILEINFO many times, it is more efficient to write an error-check procedure and merely call this procedure where necessary. The following example is a sample error-check procedure, named FILERROR. This procedure is declared at the beginning of the program; from that point on, it can be called with a single statement. The procedure contains two parameters. FILENO is an identifier through which the file number is passed. The PRINTFILEINFO intrinsic then prints a file information display for that file. QUITNO is part of the abort message printed by the QUIT intrinsic. This enables you to determine the point at which the process was aborted.
|
|