PROGRAM TRYMSG C C This program is used to demonstate the routines in the RSX-11M C error message module RSXMSG. This module is an attempt to C standardize RSX-11M error messages. Although it was mainly C written for Macro programs, it uses the Fortran calling standard C so it can be called from Fortran. As you know, Fortran has its C own runtime error messages. This module may prove useful for C those errors which are not handled by Fortran like Directive C and I/O errors returned from QIO's and other Executive directives. C C The format used for the messages are based on the VAX/VMS message C standard which has the following format: C C %facility_name-severity_level-message_identifier, text_of_message C C The facility name defaults to SYSTEM. I suggest this name be the C name of the program running (i.e., QWIKNET, QPLOT, etc.). C C The severity_level is currently not implemented (IS IT NEEDED ?) C C The message_identifier is the symbolic error code. For example, C IE.PRI is the error code for Privilege violation. C C The text_of_message is the error description. The description is C the same as that documented in the I/O Operations manual. C C Message Flag Bit Definitions C ---------------------------- C Bits in the message flag word can be cleared to inhibit printing C of various fields of the message (i.e., facility_name, C message_identifier, or text_of_message). If an attempt is made C to inhibit the printing of all fields, the default message flag C value is used. The default is to print all fields. C C The bit definitions are: C C Message flag bits (VAX/VMS equivalent): C C Bit 0 = 1 - Include text of message. C 0 Do not include text of message C C Bit 1 = 1 - Include message identifier. C 0 Do not include message identifier. C C Bit 2 = x - Severity level indicator not implemented. C C Bit 3 = 1 - Include facility name. C 0 - Do not include facility name. C C Bits 4-15 are unused and should be zero. C C C Error Codes C ----------- C Both Directive and I/O codes can be passed to the routines below. C The FCS convention is used to distinguish the difference between C the two types of error codes. That is, if it is a Directive error, C the high byte must be sign extended (-1), and if it is an I/O error, C the high byte must be zero. C C Logical Unit Number Assignment C ------------------------------ C Logical Unit Number (LUN) 6 is used for the terminal output. If C LUN 6 is not assigned when one of the routines below are called, C it is assigned to LUN 6 before writing the message. If LUN 6 is C not assigned to a terminal, an IOT is executed to abort the program. C The LUN checking is ONLY performed when a message is directed to C the terminal. Otherwise the message is simply returned in the C buffer specified (see GETMSG). C C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C C The three entry points in RSXMSG are described below. C C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C C SIGNAL - signals an error message to the terminal. C C Calling sequence: C C CALL SIGNAL(ERRCOD) C C Where: C ERRCOD - the Directive, I/O error, or success code. C C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C C PUTMSG - puts a message to the terminal. This is the same as C SIGNAL except you can control what part of the message C to be put to the terminal. C C Calling sequence: C C CALL PUTMSG(ERRCOD,,MSGFLG,FACNAM,STATUS) C C Where: C ERRCOD - the Directive or I/O error code. C MSGFLG - the message flag word. If omited, the C default is to list all fields of the message. C FACNAM - the Facility name (termnated by NULL). If omited, C the default facility name of SYSTEM is used. C STATUS - the return status word (may be omited). C Return values are: C -1 if the message code was invalid (no such message). C +n is returned to indicate the message byte count. C C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C C GETMSG - returns a message to the user program. This call is C identical to PUTMSG except a buffer must be specified C to return the message to. If the buffer is omited, the C call is the same as PUTMSG (message goes to the terminal). C C Calling sequence: C C CALL GETMSG(ERRCOD,OUTBUF,MSGFLG,FACNAM,STATUS) C C Where: C All parameters are the same as PUTMSG except OUTBUF. C OUTBUF - buffer address to receive the message. The C end of the message is terminated with a NULL. C C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C C As stated earlier, the above routines can also be called from Macro. C All you have to do is build the Fortran compatible argument block and C use a CALL (JSR PC,xxxxx) to the appropriate routine. C C The argument block for CALL SIGNAL is: C C ARGBLK: .BYTE 1,0 ; Number of arguments (ignored C ; but must be specified) C .WORD ERRCOD ; Address of error code. C C ERRCOD: .WORD error_code ; The error code to be passed. C C The argument block for GETMSG and PUTMSG is: C C ARGBLK: .BYTE 5,0 ; Number of arguments. C .WORD ERRCOD ; Address of error code. C .WORD OUTBUF ; Address of output buffer. C .WORD MSGFLG ; Address of message flags word. C .WORD FACNAM ; Address of facility name. C .WORD STATUS ; Address for return status. C C ERRCOD: .WORD 0 ; The error code to be passed. C C OUTBUF: .BLKB 100. ; The output buffer (for GETMSG). C C MSGFLG: .WORD 0 ; Message flag bits. C C FACNAM: .ASCIZ %TRYMSG% ; Facility name. C .EVEN C STATUS: .WORD 0 ; Status return word. C C Any of the parameters (except ERRCOD of course) can be omited. C To show a parameter is omited, fill the word with -1. This is C the method Fortran uses to show omited parameters. C C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C C The following is the output from running this program: C C $ RUN TRYMSG C %SYSTEM-IE.PRI, Privilege violation C %SYSTEM-IS.SUC, Successful operation C %TRYMSG-IE.BDV, Bad device name C IE.NSF, No such file(s) C No such file(s) C %TRYMSG-IE.UPN, Insufficient dynamic memory C C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INTEGER*2 FERR, FCS1, FCS2, LUN INTEGER*2 ERRCOD, MSGFLG, STATUS LOGICAL*1 FACNAM(7), OUTBUF(100) PARAMETER IOLUN = 1 ! File I/O LUN. DATA FACNAM /'T','R','Y','M','S','G',0/ C C Test the SIGNAL subroutine. C ERRCOD = -16 ! -16. is Privilege violation. CALL SIGNAL(ERRCOD) ! Just pass the error code. ERRCOD = 1 ! +01. is Successful completion CALL SIGNAL(ERRCOD) C C Test the PUTMSG routine. C CALL ERRSET(29,.TRUE.,.FALSE.,.TRUE.,.FALSE.) ! No such file. CALL ERRSET(42,.TRUE.,.FALSE.,.TRUE.,.FALSE.) ! No such device. CALL ERRSET(43,,.FALSE.,,.FALSE.,) ! Bad filspec. C C Force the I/O error "Bad device name." C OPEN (UNIT=IOLUN, NAME='DL2:XYZZY.FOO', TYPE='OLD', ERR=100) STOP 'We don''t have a DL2: on our VAX ???' C C Now get the error numbers. C FERR = Fortran error, FCS1 = FCS F.ERR value, C FCS2 = FCS F.ERR+2, LUN = erroring LUN #. C 100 CALL ERRSNS(FERR,FCS1,FCS2,LUN) IF (FCS1 .NE. 0) CALL PUTMSG(FCS1,,,FACNAM,STATUS) IF (FCS2 .NE. 0) CALL PUTMSG(FCS2,,,FACNAM,STATUS) C C Force the I/O error "File not found". C OPEN (UNIT=IOLUN, NAME='XYZZY.FOO', TYPE='OLD', ERR=200) STOP 'Do you have a file called XYZZY.FOO ???' 200 CALL ERRSNS(FERR,FCS1,FCS2,LUN) C C Pass the message flag word to include the error_identifier C and the text_of_message. C MSGFLG = 3 IF (FCS1 .NE. 0) CALL PUTMSG(FCS1,,MSGFLG,FACNAM,STATUS) IF (FCS2 .NE. 0) CALL PUTMSG(FCS2,,MSGFLG,FACNAM,STATUS) C C Alter the message flag to include only the text_of_message. C MSGFLG = 1 IF (FCS1 .NE. 0) CALL PUTMSG(FCS1,,MSGFLG,FACNAM,STATUS) IF (FCS2 .NE. 0) CALL PUTMSG(FCS2,,MSGFLG,FACNAM,STATUS) C C Now use GETMSG to return a message to the program. C ERRCOD = -1 ! Insufficient dynamic storage. CALL GETMSG(ERRCOD,OUTBUF,,FACNAM,STATUS) C C The return STATUS is either -1 for bad message, or the C message byte count if successful. C IF (STATUS .NE. -1) WRITE (6,300) (OUTBUF(I),I=1,STATUS) 300 FORMAT (1X,A1) CALL EXIT END