There are basically two types of errors that can occur as
a result of calling VPLUS intrinsics. The first type consists of
errors in the intrinsic call itself or in an attempt to access a
file used by the called intrinsic. The second type are errors detected
by editing data entered into FORMSPEC forms. These two error types
are handled differently by VPLUS.
Intrinsic Call or File Errors |
|
If a call to a VPLUS intrinsic causes an error so that the
intrinsic cannot be executed correctly, or if an MPE file error
occurs as a result of an attempt to access a file with a VPLUS intrinsic,
the comarea word cstatus is set to a nonzero value. In addition, the number
associated with an MPE file error is stored in the comarea word, filerrnum.
When cstatus is not zero, any subsequent VPLUS intrinsics called
by the application return to the application without executing.
As part of good programming practice, check cstatus after each call, report the error, and then reset cstatus. There is one exception — VERRMSG uses cstatus to determine the error number. If cstatus is set to zero (indicating no error) prior to the
call to VERRMSG, then no message is returned.
Editing Errors |
|
Field processing may be specified in the forms description
with FORMSPEC and checked by VFIELDEDITS, VINITFORM, or VFINISHFORM; or editing may be provided by user routines in
an application.
Each field in a FORMSPEC form has an error flag associated
with it. When one of the VPLUS intrinsics that performs field processing
(VFIELDEDITS, VINITFORM or VFINISHFORM) detects a field error, it sets the error flag
for that field. It also increments numerrs, the word in comarea that contains the total number of fields with errors
in each form. If a user-provided editing routine detects a field
error, the program must call the VPLUS intrinsic VSETERROR in order to set the field error flag and increment numerrs. The cstatus item is not set when an editing error is detected
and subsequent intrinsics may be executed without resetting this comarea item.
If new data is written to a field in the data buffer that
had an error, the error flag for the field is cleared and nurnerrs is decremented. VPUTBUFFER, VPUTFIELD, or VPUTtype are the intrinsics that can correct field errors
and decrement numerrs. The intrinsic VREADFIELDS resets numerrs to zero when it reads new data into the buffer from
the terminal. If numerrs has been set to a nonzero value by one of the VPLUS
edit intrinsics, then VREADFIELDS with reset it to zero. Also, when VGETNEXTFORM is called, nurnerrs is reset to zero.
Error Messages |
|
Messages associated with all VPLUS-detected errors can be
retrieved by a call to VERRMSG. This intrinsic uses the error message file whose
MPE file number is kept in the comarea word, errfilenum The error message file contains internal error numbers
linked to particular field errors. Error messages may be general
VPLUS messages (see Appendix B), or custom messages specified during
forms design with FORMSPEC. In either case, the message is returned
to the calling program by VERRMSG. VERRMSG determines the type of the error by examining cstatus and numerrs. If cstatus is not zero, its value indicates a particular intrinsic
call error. If cstatus is zero and numerrs is set, VERRMSG knows the error is an editing error and uses internal
values to locate the error in the error message file. If an editing
error is detected by a user routine, the program must provide its
own message when it calls VSETERROR to set the error flag for the field.
Determining Fields in Error |
|
VGETFORMINFO provides a method of determining which fields
are flagged in error by the editing routines. VFIELDEDITS sets an error flag for each field that failed
edit checks. Only the error number of the first field in error and
the number of errors have been returned to an application by VFIELDEDITS via the comarea. All fields in error are enhanced with the error
enhancement if VSHOWFORM is called after VFIELDEDITS. To enable applications to determine which fields
are in error for a given form at run-time, VGETFORMINFO optionally returns data about these error flags
to show which fields failed the edit checks.