HPlogo Message Catalogs:Programmer's Guide: HP 3000 MPE/iX Computer Systems > Appendix D FORTRAN Progam Examples

Example of Accessing the NM Error Message Catalog

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The following listing is a FORTRAN program that inserts the value 42 into message number 8 in message set 201 in the message catalog SYSCAT.PUB.SYS. The message is output to $STDLIST. The accessed portion of the message catalog is:

       $SET 201 

          . 

          . 

          . 

       008 The value passed for parameter #! is invalid. 
$control standard_level system 

   * 

        program NM_MSGCAT 

   * 

        system intrinsic QUIT 

   * 

        integer*2    SETNUM 

       2            ,MSGNUM 

       3            ,MSGDEST 

       4            ,MSGLENGTH 

   * 

        integer CATINDEX 

       2       ,CATSTATUS(2) 

   * 

        logical STATUS_RETURN 

   * 

        character DESIGNATOR*20 

       2         ,PARM1*3 

   * 

        DESIGNATOR = 'SYSCAT.PUB.SYS' 

        call OPEN_SYSCAT (DESIGNATOR 

       2                 ,CATINDEX 

       3                 ,STATUS_RETURN) 

        if (STATUS_RETURN) go to 10 

        print *,'OPEN_SYSCAT Failed.  Terminating.' 

        call QUIT (1) 

   * 

   10 SETNUM     = 221 

      MSGNUM     = 8 

      PARM1(1:2) = '42' 

      write (PARM1(3:3),15) 0b 

   15 format (r1) 

        MSGDEST = 0 

   * 
        call READ_SYSCAT (CATINDEX 

       2                 ,SETNUM 

       3                 ,MSGNUM 

       4                 ,PARM1 

       5                 ,MSGDEST 

       6                 ,STATUS_RETURN) 

   * 

        if (STATUS_RETURN) go to 20 

        print *,'READ_SYSCAT Failed.  Terminating.' 

        call QUIT (2) 

   * 

   20 call CLOSE_SYSCAT (CATINDEX 

       2                ,STATUS_RETURN) 

        if (STATUS_RETURN) go to 30 

        print *,'CLOSE_SYSCAT Failed.  Terminating' 

        call QUIT (3) 

   * 

   30 stop 

        end 

   * 

   ******************************************************* 

   * 

        subroutine OPEN_SYSCAT (DESIGNATOR 

       2                       ,CATINDEX 

       3                       ,STATUS_RETURN) 

   * 

        system intrinsic CATOPEN 

   * 

        integer CATINDEX 

       2       ,CATSTATUS(2) 

   * 

        logical STATUS_RETURN 

   * 

        character DESIGNATOR*20 

   * 

        STATUS_RETURN = .true. 

        CATINDEX = CATOPEN (DESIGNATOR, CATSTATUS) 

        if (CATSTATUS(1) .ne. 0) STATUS_RETURN = .false. 

   * 

        return 

        end 

   * 

   ******************************************************* 

   * 

        subroutine READ_SYSCAT (CATINDEX 

       2                       ,SETNUM 

       3                       ,MSGNUM 

       4                       ,PARM1 

       5                       ,MSGDEST 

       6                       ,STATUS_RETURN) 

   * 

        system intrinsic CATREAD 

   * 
        integer*2 SETNUM 

       2         ,MSGNUM 

       3         ,MSGDEST 

       4         ,MSGLENGTH 

       5         ,CATSTATUS(2) 

   * 

        integer*4 CATINDEX 

       2         ,DUMY 

   * 

        logical STATUS_RETURN 

   * 

        character PARM1*3 

   * 

        STATUS_RETURN = .true. 

        MSGLENGTH = CATREAD (CATINDEX 

       2                    ,SETNUM 

       3                    ,MSGNUM 

       4                    ,CATSTATUS 

       5                  ,,,PARM1 

       6                ,,,,,MSGDEST) 

        if (CATSTATUS(1) .ne. 0) STATUS_RETURN = .false. 

        return 

        end   

   * 

   ******************************************************* 

   * 

        subroutine CLOSE_SYSCAT (CATINDEX   

       2                        ,STATUS_RETURN) 

   * 

        system intrinsic CATCLOSE 

   * 

        integer*2 CATSTATUS(2) 

   * 

        integer*4 CATINDEX 

   * 

        logical STATUS_RETURN 

   * 

        STATUS_RETURN = .true. 

        call CATCLOSE (CATINDEX 

       2              ,CATSTATUS) 

        if (CATSTATUS(1) .ne. 0) STATUS_RETURN = .false. 

        return 

        end 

When this program is executed, the output is:

   The value passed for parameter #42 is invalid 
Feedback to webmaster