[INHERIT('SYS$LIBRARY:STARLET')] PROGRAM Handler(INPUT,OUTPUT); { This program will demonstrate how to write } { a condition handler that will catch an } { error, set a outer-level variable, and GOTO } { a cleanup section. } PROCEDURE Level1; LABEL Error_Return; { Note that the layout of the mechanism array } { is different on VAX and Alpha systems. See } { the OpenVMS Calling Standard and the Compaq } { Pascal User Manual for OpenVMS Systems for } { additional information on the contents of the } { mechanism array. } TYPE Signal_Array = ARRAY [0..1] OF INTEGER; Mechanism_Array = ARRAY [0..(SIZE(CHF2$TYPE) DIV 4)-1] OF INTEGER; Large_Basetype = ARRAY [0..MAXINT DIV 16] OF CHAR; VAR Large_Array : ^Large_Basetype; Handler_Status : [VOLATILE] INTEGER VALUE 0; [ASYNCHRONOUS] FUNCTION Handler( VAR Sig_Args : Signal_Array; VAR Mech_Args : Mechanism_Array):INTEGER; BEGIN IF Sig_Args[1] <> SS$_UNWIND THEN BEGIN Handler_Status := Sig_Args[1]; GOTO Error_Return; END ELSE Handler := SS$_RESIGNAL; END; BEGIN ESTABLISH(Handler); { Try to allocate a very large array that } { will result in an error being signalled } { by the call to NEW. } NEW(Large_Array); Error_Return: IF Handler_Status <> 0 THEN BEGIN WRITELN('Handler_Status = ',HEX(Handler_Status)); END; END; BEGIN Level1; END.