	PROGRAM WTQUE
C
C	THIS PROGRAM ILLUSTRATES THE NECESSARY STEPS TO WRITE A MESSAGE
C	TO THE MA QUEUE.  
C
C	WRITTEN BY: D. LUECK   12/22/87
C
	IMPLICIT COMPLEX (A-Z)

	PARAMETER	EFN = 1		! QIO TO QUEUE SYNC EVENT FLAG
	PARAMETER	IZQ = 1		! QUEUE LUN
	PARAMETER	CNS = 6		! CONSOLE LUN
	PARAMETER	MSGLEN = 50	! MAX MESSAGE SIZE
	PARAMETER	QUESUC = "401	! SUCCESS STATUS
	PARAMETER	ITYPE = 0	! TYPE 0 MESSAGE (I.E. CAN BE
					!   DELETED IF QUEUE IS FULL AND
					!   ANOTHER MESSAGE NEEDS TO BE QUEUED)
	
	INTEGER*2	STATUS		! QUEUE FUNCTION STATUS
	BYTE		STATB(2)	! STATUS AS 2 BYTES
	EQUIVALENCE	(STATUS,STATB)	
	CHARACTER*16	MSGID		! MESSAGE ID SUBQUEUE TO READ MSGS
					!   FROM
	CHARACTER*50	MSGBUF		! BUFFER MESSAGE READ INTO

	INTEGER*2	WRITEQ		! FUNCTION RETURN STATUS
	INTEGER*2	I		! LOOP INDEX

	DATA	MSGID	/'SAMPLE_QUEUE'/	! MESSAGE ID NAME
	DATA	MSGBUF	/'SAMPLE MESSAGE WRITTEN TO MESSAGE ID SAMPLE_QUEUE '/
C			  12345678901234567890123456789012345678901234567890

C 	PROGRAM START
C 	-------------

	DO 50 I=1,10				! WRITE TEN MESSAGES

	STATUS = WRITEQ(IZQ,EFN,MSGID,MSGBUF,
	1	        MSGLEN,ITYPE)		! WRITE MESSAGE TO QUEUE
						!   TRY TO ACK IT
	IF (STATUS.NE.QUESUC) THEN	     	! BAD STATUS
		WRITE (CNS,30) STATB(1),STATB(2)
30		FORMAT(' WTQUE -- BAD QUEUE STATUS',
	1	       ' ON WRITE TO QUEUE .. FATAL'/
	2	       '    DIRECTIVE STATUS.. ',I5/
	3	       '    I/O STATUS........ ',I5)
		GOTO 9000
	ELSE 
		WRITE (CNS,40)
40		FORMAT(' WTQUE -- MESSAGE QUEUED SUCCESSFULLY')
	END IF		
		
50	CONTINUE

9000	CONTINUE
	END
