MODULE msgmod (IDENT = '002' , %IF %BLISS(BLISS32) %THEN LANGUAGE(BLISS32), ADDRESSING_MODE(EXTERNAL = LONG_RELATIVE , NONEXTERNAL = LONG_RELATIVE) %ELSE LANGUAGE(COMMON) %FI %TITLE 'PRETTY - MSGMOD module' ) = BEGIN !++ ! FACILITY: PRETTY ! ! ! ABSTRACT: ! This facility is used to print messages. The interface to this facility ! is through the keyword macro $BLF_MESSAGE. The require file MISC.REQ ! contains the macro declaration and other declarations that any module ! needs to be able to call the macro. ! ! The only action that the macro $BLF_MESSAGE takes is to call the routine ! BLF$_MSG. This module contains that routine. For more details, see the ! documentation file MSGDOC.MEM. ! ! ENVIRONMENT: ! VAX/VMS V2.3. Most of the module is transportable; however, the code ! that deals with a message of Type = Standard Message makes use of the ! standard error message facility supplied by VAX/VMS. ! ! CREATION DATE: 09-JUL-81 ! ! MODIFIED BY: ! 01 SD 04-AUG-81 Incorporate the XCODE parameter to allow for ! two line messages. ! ! 02 MCC 17-AUG-81 -TO WORK ON THE INTERFACE FOR ERROR MESSAGES. ! ! 21-Dec-81 TT Took what I needed and changed the names to BLF. ! !-- ! ! TABLE OF CONTENTS: ! FORWARD ROUTINE BLF$_MSG : NOVALUE ; ! The message writing routine. ! ! INCLUDE FILES: ! LIBRARY 'SYS$LIBRARY:XPORT'; ! All I/O uses XPORT. REQUIRE 'BLFIOB.REQ' ; REQUIRE 'MSGMAC.REQ' ; ! ! MACROS: None ! ! ! EQUATED SYMBOLS: None ! ! ! OWN STORAGE: None ! %SBTTL 'blf$_msg' GLOBAL ROUTINE blf$_msg (type , code , xcode , str_desc , fao1 , fao2 ) : NOVALUE = !++ ! ! FUNCTIONAL DESCRIPTION: ! ! This routine implements the message writing facility. ! ! FORMAL PARAMETERS: ! ! type = Contains an integer code that specifies the type of message to ! be printed. It can have one of four values: ! 1 ==> Output ! 2 ==> Debug *** commented out *** ! 3 ==> Xport *** commented out *** ! 4 ==> Standard Message ! code = Contains an integer code that specifies a message in a message ! file. ! xcode = Contains the integer code that specifies a secondary message to ! be included along with the main message specified by "code". ! str_desc = Contains the address of a string descriptor for the string ! that the user specified in the macro call. ! fao1 = Contains the address of a string descriptor of a string ! that the caller wants to use as an FAO argument of a ! standard message. ! fao2 = Same as FAO1. ! ! ***** NOTE: None of the actual parameters are modified. ! ! ! IMPLICIT INPUTS: ! ! This routine makes use of the debug flag blf$k_debug and the terminal ! I/O control block used by XPORT. These data segments are declared ! as EXTERNAL in MISC.REQ. It is assumed that these variables are declared ! as global in some other module. ! ! IMPLICIT OUTPUTS: ! ! Messages get printed to SYS$OUTPUT and/or SYS$ERROR. ! ! ROUTINE VALUE: None ! COMPLETION CODES: ! ! None ! ! SIDE EFFECTS: ! ! None ! !-- BEGIN ! OWN ! severity_bits ; ! Needed for the severity check of ! messages of TYPE = Standard Message. !+ ! The body of the routine is one CASE statement. Depending on the ! type of message indicated by the parameter "type" one of the ! sections of code is executed. !- CASE .type FROM 1 TO 4 OF SET !+ ! Note that ypes Xport and Debug have been commented out because they ! aren't used at the present time. They do work, however. !- [1]: !+ ! Type = Output ! ! The user calls this type to have a character string written to the ! terminal. !- IF (.str_desc EQL -1) THEN !+ ! The caller did not specify the STRING parameter; Therefore, ! write out a default message. !- $XPO_PUT (IOB = tty_iob, STRING = 'Default $BLF_MESSAGE Message') ELSE !+ ! The caller specified STRING. Write out the string. !- $XPO_PUT (IOB = tty_iob, STRING = .str_desc ) ; [2,3]: 0; ! [2]: !+ ! ! Type = Debug ! ! ! ! This type of message is similar to the "output" type. ! ! ! ! The main difference is that the message is written only if ! ! the debug flag "blf$k_debug" is set. The string gets prefixed ! ! with the string "DEBUG: ". ! !- ! ! IF (.blf$k_debug) THEN ! IF (.str_desc EQL -1) THEN ! !+ ! ! The caller did not specify the STRING parameter. ! ! Print out the default message. ! !- ! $XPO_PUT (IOB = tty_iob , ! STRING = $STR_CONCAT ('DEBUG: ' , ! 'Default $blf_MESSAGE Message')) ! ELSE ! !+ ! ! The caller specified STRING. Write out the string. ! !- ! $XPO_PUT (IOB = tty_iob , ! STRING = $STR_CONCAT ('DEBUG: ', .str_desc ) ) ; ! ! ! [3]: !+ ! ! Type = Xport ! ! ! ! The XPORT package provides the macro $XPO_PUT_MSG to deal with ! ! XPORT errors. That facility is made use of here. If such an ! ! error occurs, $XPO_PUT_MSG is called to signal the error. ! ! ! ! NOTE: The severity of any errors signalled in this way is forced ! ! to be WARNING so that calling TYPE = XPORT never results in ! ! automatic termination of the program. ! !- ! ! IF (.str_desc EQL -1) THEN ! !+ ! ! The caller did not specify the STRING parameter. ! !- ! $XPO_PUT_MSG (CODE = .code , ! SEVERITY = WARNING) ! ELSE ! !+ ! ! The caller specified STRING. Write it out along with the ! ! standard XPORT message specified by CODE. ! !- ! $XPO_PUT_MSG (CODE = .code , ! STRING = .str_desc , ! SEVERITY = WARNING) ; ! ! [4]: !+ ! Type = Standard Message ! ! This is the type of message that the caller requests in order to ! print out a BLF message in the host system's standard message ! format. ! ! *** IMPORTANT NOTE *** ! ! This is the section that is specific to the VAX. When BLF is ! installed on other host systems it will be necessary to expand ! this section. More specifically, it is the call to SIGNAL that ! may operate differently on other host systems. !- BEGIN !+ ! Signaling a severe error automatically terminates the program. ! It is usually necessary to call a cleanup routine before allowing ! the program to terminate. Therefore, if the error being signalled ! is severe, the CLEANUP parameter is checked before signaling the ! error. If the CLEANUP parameter is set, the cleanup routine ! is called. !- ! Mask out all bits except the severity level bits. ! severity_bits = .code AND 7 ; ! IF (.severity_bits GEQ 4) AND (.cleanup) THEN ! BEGIN ! IF (.blf$k_debug) THEN ! $XPO_PUT (IOB = tty_iob , ! STRING = 'DEBUG: Calling rec$_clean_db') ; ! rec$_clean_db () ; ! END ; !+ ! Signal the message. The parameters to be included in the call ! to SIGNAL depend on the FAO arguments that the ! caller specified, and whether or not XCODE was specified. !- IF (.xcode EQL -1) THEN ! The XCODE parameter was not specified. BEGIN ! If FAO1 is unspecified, then FAO2 is also unspecified. IF (.fao1 EQL -1) THEN SIGNAL (.code, 0) ; IF (.fao1 GTR -1) AND (.fao2 EQL -1) THEN ! Only FAO1 is specified. SIGNAL (.code , 1, .fao1) ; IF (.fao2 GTR -1) THEN ! If FAO2 is specified, then so must be FAO1. SIGNAL (.code, 2, .fao1, .fao2) ; END ELSE ! The XCODE parameter was specified. BEGIN IF (.fao1 EQL -1) THEN ! If FAO1 is unspecified, then FAO2 is also unspecified. SIGNAL (.code, 0, .xcode, 0) ; IF (.fao1 GTR -1) AND (.fao2 EQL -1) THEN ! Only FAO1 is specified. SIGNAL (.code , 1, .fao1, .xcode, 0) ; IF (.fao2 GTR -1) THEN ! If FAO2 is specified, then so must be FAO1. SIGNAL (.code, 2, .fao1, .fao2, .xcode, 0) ; END ; END ; ! Standard Message [OUTRANGE]: ! The programmer has specified an invalid TYPE. BEGIN $XPO_PUT (IOB = tty_iob , STRING = 'Invalid TYPE specified in call to $BLF_MESSAGE.') ; END ; TES ; END; ! End of routine END ! End of module ELUDOM