HP Pascal/iX Programmer's Guide (31502-90023)

11- 11
to execute. If AbortFlag is not zero, the Pascal run-time
library prints an error message and aborts the program.
To trap all run-time library errors and have them invoke your Library
Trap Handler, call XLIBTRAP this way:
XLIBTRAP (
baddress
(
My_Library_Trap_Handler
),
OldPLabel
);
To disable your Library Trap Handler, pass zero to XLIBTRAP as the first
parameter.
Example
{the user declares the following Pascal record for the PStkMrk record}
TYPE
PStkMrk = RECORD {"Stack Marker"}
users_PCS,
users_PCO,
users_SP,
users_DP : integer;
END;
$INCLUDE '/usr/include/pasesc.ph'$ {this file lists all the Pascal
run-time library error codes
for the HP-UX operating system}
PROCEDURE My_Library_Trap_Handler (VAR StkRec : PStkMrk;
VAR ErrorCode : Integer;
VAR AbortFlag : Integer
);
BEGIN {My_Library_Trap_Handler}
{ignore file close errors, abort on all others}
IF (ErrorCode = PasErr_CloseError) THEN BEGIN
writeln ('Oops! File close error, continue execution');
AbortFlag := 0; {no abort}
END
ELSE
AbortFlag := 1; {print message and abort}
END; {My_Library_Trap_Handler}
XARITRAP Intrinsic
The MPE/iX intrinsic XARITRAP is supported by the Trap Subsystem.
XARITRAP enables your program to arm an arithmetic trap handling
procedure (Arithmetic Trap Handler). Subsequently, any arithmetic error
causes this Arithmetic Trap Handler to be called, allowing the user to
decide whether to abort or continue the program, or correct the error.
For more information on trap handling, see the
Trap Handling Programmer's
Guide
.
Syntax
To arm your Arithmetic Trap Handler, call XARITRAP this way:
XARITRAP (
mask, plabel, oldmask, oldplabel
);
Parameters
mask
32-bit integer by value, whose bits specify which trap
condition gets armed. The assignment of each position in
the bit mask is as follows:
Bit Error Trap