SUBROUTINE ABORT(ERROR.MESSAGE, PROGRAM.ID)
****
* ABORT - TERMINATE THE CURRENT PROCESS DUE TO A FATAL ERROR
LastUpdated... = "Rev: 15:45 24JUL90 ANDREW <COMDEV>ANDREW 161 Z <COMDEV>ANDREW>BP>ABORT.IBAS"
*
****
* DESCRIPTION
*
*     This subroutine's intended use is for the orderly return of control
* to the user after a fatal type error.
*
*     The argument list is as folows:
*
* ERROR.MESSAGE - The error message(s) to be conveyed to the user.  The
*     format is that of a dynamic array.
* PROGRAM.ID    - The name of program (the actual program) that called
*     subroutine.  It will behoove the programmer to use the actual (and
*     correct) program id so that when a fatal error does occur the actual
*     source of the problem can be identified.  This argument is multivalued:
*        PROGRAM.ID<1,1> = Actual PROGRAM.ID
*        PROGRAM.ID<1,2> = Logout control, if this value is "LOGOUT" then
*           ABORT will CHAIN "LO", otherwise it will issue a STOP.
*
****
*                           R E V I S I O N   L O G
* PR#     WHEN     WHO        WHY
* ======= ======== ========== ==========================================
* 001     14AUG86  MCLAUGHLIN Add code to release any records that may be
*                  locked.
* 002     08OCT86  MCLAUGHLIN Added coded to write @LOGNAME, @USERNO, @WHO
*                  ERROR.MSG, and a dump of the screen to a file in addition
*                  to the usual printing of the message on the screen.
* 003     04NOV86  MCLAUGHLIN Added CLEARDATA to flush any user type ahead.
* 004     10DEC86  MCLAUGHLIN BugFix Switch to half-duplex before sending
*         screen contents to computer.  To prevent garbage from printing
*         on screen.
* 005     12DEC86  MCLAUGHLIN Cause delay to prevent garbage on screen.
* 006     23MAR87  MCLAUGHLIN Add LOGOUT option to PROGRAM.ID argument.
* 007     08APR87  MCLAUGHLIN Add CLEARDATA before input screen contents.
* HC0101  04/08/87 J DIGNAN   Get all input until CR encountered; CLEARSELECT ALL
* HC0091  06-03-87 J DIGNAN   USE STANDARD INSERT FILES.
* 008     20OCT87  ATM        Let user know that they are actually in a
*                             fatal error situation, and that they should
*                             let us know right away.
* 009     24Jul90  ATM        Enhance to make code more generic.
****

**** BEGIN CODE

VOC.OPEN = @TRUE
OPEN "VOC" TO VOC.FILE ELSE VOC.OPEN = @FALSE

     PROMPT ''

     PRINTER OFF
     PRINTER CLOSE

     RELEASE                                                       ;*[001]
     CLEARSELECT ALL                                            ;*[HC0101]

     ERROR.MESSAGE.DOWNGRADED = ERROR.MESSAGE                      ;*[002]
     CONVERT @FM TO @VM IN ERROR.MESSAGE.DOWNGRADED                ;*[002]

     CALL @PTERM$('-HALF NOLF')                                    ;*[004]
     CLEARDATA                                                     ;*[007]
     PRINT ESC$:'S':                                               ;*[002]
     CALL @SLEEP$(1000)                                            ;*[004]
     INPUT SCREEN.DUMP                                             ;*[002]
     CALL @PTERM$('-FULL')                                         ;*[004]

     ABORT.FILE.KEY = DATE():'-':TIME():'-':PROGRAM.ID             ;*[002]
     ABORT.FILE.REC = ''                                           ;*[002]
     ABORT.FILE.REC<1> = @LOGNAME                                  ;*[002]
     ABORT.FILE.REC<2> = @USERNO                                   ;*[002]
     WHO = ''                                                      ;*[002]
     CALL @FULL.PATH$(WHO)                                         ;*[002]
     ABORT.FILE.REC<3> = WHO                                       ;*[002]
     ABORT.FILE.REC<4> = ERROR.MESSAGE.DOWNGRADED                  ;*[002]
     ABORT.FILE.REC<5> = SCREEN.DUMP                               ;*[002]

     ABORT.FILE.OPENED = TRUE$                                     ;*[002]
     ABORT.FILENAME    = 'ABORT.FILE'                              ;*[002]
     OPEN '',ABORT.FILENAME TO ABORT.FILE ELSE                     ;*[002]
        ABORT.FILE.OPENED = FALSE$
        READ VOC.REC FROM VOC.FILE, ABORT.FILENAME ELSE            ;*[002]
           VOC.REC = ''                                            ;*[002]
           VOC.REC<1> = 'F'                                        ;*[002]
           VOC.REC<2> = 'GLOBAL.PROD>':ABORT.FILENAME              ;*[002]
           VOC.REC<3> = 'SOURCE>DICT>D_':ABORT.FILENAME            ;*[002]
           WRITE VOC.REC TO VOC.FILE, ABORT.FILENAME               ;*[002]
           ABORT.FILE.OPENED = TRUE$
           OPEN '',ABORT.FILENAME TO ABORT.FILE ELSE               ;*[002]
              ABORT.FILE.OPENED = FALSE$                           ;*[002]
           END                                                     ;*[002]
        END                                                        ;*[002]
     END                                                           ;*[002]

     LINES = COUNT(ERROR.MESSAGE,@FM) + (ERROR.MESSAGE NE '')
     START = 22 - LINES + 1

     CONVERT LCASE$ TO UCASE$ IN PROGRAM.ID
     REMOVE PROGRAM.NAME FROM PROGRAM.ID SETTING DUMMY             ;*[006]
     PROGRAM.NAME = '(':PROGRAM.NAME:')'
     EOL = 80 - LEN(PROGRAM.NAME)

     PRINT @(0,23)
     FOR I = 1 TO LINES
        PRINT ERROR.MESSAGE<I>:@(EOL):PROGRAM.NAME:
     NEXT I
     PRINT 'This is a software failure, call MIS immediately.':@(EOL):PROGRAM.NAME:

     PRINT 'Press <RETURN> to continue . . . ':
     CLEARDATA                                                     ;*[003]
     IF ABORT.FILE.OPENED THEN                                     ;*[002]
        WRITE ABORT.FILE.REC TO ABORT.FILE, ABORT.FILE.KEY         ;*[002]
     END                                                           ;*[002]
     INPUT RESPONSE                     ;*[HC0101] GET WHOLE LINE

     REMOVE LOGOUT.OPTION FROM PROGRAM.ID SETTING DUMMY
     IF LOGOUT.OPTION EQ "LOGOUT" THEN                             ;*[006]
        CHAIN "LO"                                                 ;*[006]
     END

     STOP

  END
