	
	PROGRAM PAMSAMPLE

	INCLUDE '($SSDEF)'

	INCLUDE 'dmq$user:dmq(PAMS_FOR_GROUP)'		!* Target/Source Group num
	INCLUDE 'dmq$user:dmq(PAMS_FOR_PROCESS)'		!* Target/Source Process num
	INCLUDE 'dmq$user:dmq(PAMS_FOR_TYPE_CLASS)'		
	INCLUDE 'dmq$user:dmq(PAMS_FOR_ENTRY_POINT)'
	INCLUDE 'dmq$user:dmq(PAMS_FOR_RETURN_STATUS)'
	INCLUDE 'dmq$user:dmq(PAMS_FOR_SYMBOL_DEF)'

	INTEGER*2 SUB

	INTEGER*2 PRIORITY, CLASS, TYPE, MSG_AREA_LEN, LEN_DATA, MSG_SIZE
	INTEGER*2 JOURNAL
	INTEGER*4 SOURCE, STATUS, TARGET, TIMEOUT, EXIT_STATUS
	INTEGER*4 SYS$EXIT, DCLED_Q_ADDRESS
        INTEGER*4 ATTACH_MODE, Q_TYPE, Q_NAME_LEN

	BYTE MSG_AREA(80),Q_NAME(32)
	CHARACTER*80 INQUIRY_AREA
	EQUIVALENCE (MSG_AREA, INQUIRY_AREA)

	CHARACTER OPTION

	TIMEOUT	= 50
	MSG_AREA_LEN = 80
	PRIORITY     = 0
	EXIT_STATUS  = 1

        ATTACH_MODE = PSYM_ATTACH_TEMPORARY
        Q_TYPE = PSYM_ATTACH_PQ
        STATUS = PAMS_ATTACH_Q (ATTACH_MODE,DCLED_Q_ADDRESS,Q_TYPE,
     1                          0,0,0,0,0,0,0)

	IF (.NOT. STATUS) CALL LIB$SIGNAL(%VAL(STATUS))

100	CONTINUE

	TYPE *,' '
	TYPE *,' 			(G)  PAMS_GET_MSG  '
	TYPE *,' 			(W)  PAMS_GET_MSGW  '
	TYPE *,' 			(P)  PAMS_PUT_MSG  '
	TYPE *,' 			(E)  EXIT '
	TYPE *,' '

	WRITE(*,FMT=('(A)'))  '$ 	ENTER OPTION:  '
	READ (*,FMT=('(A)'))  OPTION

	IF (OPTION .EQ. 'G') GOTO 2000
	IF (OPTION .EQ. 'W') GOTO 3000
	IF (OPTION .EQ. 'P') GOTO 4000
	IF (OPTION .EQ. 'E') GOTO 9999

	TYPE *,' * INVALID OPTION ENTERED - TRY AGAIN '
	GOTO 100

2000	CONTINUE
	STATUS = PAMS_GET_MSG (MSG_AREA, PRIORITY, SOURCE, CLASS, TYPE, 
	1                      MSG_AREA_LEN, LEN_DATA)

	GOTO 3500

3000	CONTINUE
	STATUS = PAMS_GET_MSGW (MSG_AREA, PRIORITY, SOURCE, CLASS, TYPE, 
	1                       MSG_AREA_LEN, LEN_DATA, TIMEOUT)


3500	CONTINUE
	IF (STATUS .EQ. %LOC(PAMS__TIMEOUT))  THEN
	    TYPE *,' TIMEOUT PERIOD EXPIRED '
	    GOTO 100
	    ENDIF

	IF (.NOT. STATUS) THEN 
	    CALL LIB$SIGNAL(%VAL(STATUS))
	    GOTO 100
	    ENDIF

	IF (STATUS .EQ. %LOC(PAMS__NOMOREMSG)) 
	1    TYPE *,' NO MORE MSGS '

	IF (STATUS .EQ. SS$_NORMAL) THEN
	    TYPE *,' '
	    TYPE *,' PAMS_GET_MSG OR PAMS_GET_MSGW CALL OK'
	    TYPE *,' SOURCE =',SOURCE
	    TYPE *,' CLASS  =',CLASS
	    TYPE *,' TYPE   =',TYPE
	    TYPE *,' LEN_DATA =',LEN_DATA
	    TYPE *,' STATUS =',STATUS

	    DO SUB = 1, LEN_DATA
	      TYPE *,' MSG_AREA(*) =',MSG_AREA(SUB)
	    ENDDO
	ENDIF
	GOTO 100


4000	CONTINUE

	TYPE *,'ENTER THE MSG TO BE SENT'
	READ (*,4100) MSG_SIZE, INQUIRY_AREA
4100	FORMAT(Q, A)
	DO SUB = 1, LEN_DATA
	    TYPE *,' MSG_AREA(*) =',MSG_AREA(SUB)
	ENDDO
	TYPE *,' THE MSG SIZE IS ',MSG_SIZE

	CLASS  = 10
	TYPE   = 500
	TARGET = DCLED_Q_ADDRESS

	STATUS = PAMS_PUT_MSG (MSG_AREA, PRIORITY, TARGET, CLASS, TYPE, 
	1                                         JOURNAL, MSG_SIZE)

	IF (STATUS) THEN
	    TYPE *,' PAMS_PUT_MSG CALL OK'
	 ELSE
	    CALL LIB$SIGNAL(%VAL(STATUS))
	 ENDIF

	GOTO 100


9999	CONTINUE
	STATUS = SYS$EXIT( %VAL(EXIT_STATUS) )
	END
