C*	QXMN	- QX MAIN ROUTINE
C
	PROGRAM QX
C
C	$$$QX, FOR QUEUE EXTENDED, REPORTS ON ENTRIES IN THE
C	SPOOL QUEUES.  IT HAS OPTIONS WHICH ENABLE IT TO LIST
C	EXPECTED PRINT TIME AND PAGES AND ALSO GIVE EXPANDED LISTINGS
C	OF THE FILES CONTAINED IN CONCATENATED OUTPUT.
C
C	TO RUN QX -
C	PDS> QX [/SWITCHES]
C
C	NOTE THAT QX WITH NO SWITCHES IS EQUIVALENT TO QUEUE/ALL.
C
C	THE AVAILABLE SWITCHES ARE AS FOLLOWS -
C
C		/TI[:FILESPEC]	- LIST THE PRINT TIME AND PAGES FOR FILES
C				  QUEUED FOR PRINTING.  IF IT IS A CONCATENATED
C				  ENTRY, ALL THE FILES IN THAT ENTRY ARE SUMMED
C				  UP AND THE TOTALS PRINTED.
C				  IF /TI:FILESPEC IS USED, PRINT TIME AND PAGES
C				  ARE REPORTED FOR THAT FILE ALONE AND THE QUEUE
C				  IS NOT SEARCHED.  THIS IS USEFUL TO EXAMINE AN
C				  OUTPUT FILE FOR PRINT TIME BEFORE IT IS QUEUED
C				  FOR PRINTING.
C
C		/EC		- EXPAND CONCATENATED ENTRIES.  INDIVIDUAL
C				  ENTRIES IN A CONCATENATED LIST WILL BE LISTED.
C
C		/OW		- LIST ONLY THOSE FILES ASSOCIATED WITH THE
C				  CURRENT USERS DEFAULT UIC.  THIS IS EQUIVALENT
C				  TO QUEUE/LI.
C
C		/PD		- PRINT DEFERRED.  THIS SWITCH WILL LIST THE
C				  FILES IN THE 'PRINT DEFERRED' QUEUE.  THESE
C				  FILES ARE ONES WHICH ARE NOT YET QUEUED FOR
C				  PRINTING, BUT ARE FUTURE CONCATENATED ENTRIES.
C				  LISTS FILES OF USERS WHO HAVE PDS> SET PRINT
C				  DEFERRED AND NOT YET ISSUED PDS> SET PRINT NO
C				  DEFERRED.  ALSO LISTS THE FILES BEING GENERAT-
C				  ED BY ACTIVE BATCH JOBS, I.E BATCH.LOG AND
C				  LP.SPR FILES.
C
C		/RE		- RECOVER (NOT IMPLEMENTED YET).  THIS SWITCH
C				  WILL GENERATE A FILE WHICH CONTAINS PDS PRINT
C				  COMMANDS FOR EVERY FILE IN THE QUEUE.  THIS
C				  WILL BE USEFUL IF SPRQUEUE.SYS NEEDS TO BE
C				  DELETED.  USING QX/RE WILL CONSTRUCT THE
C				  PRINT STATEMENTS IN THE PROPER SEQUENCE SUCH
C				  THAT WHEN THE FILE IS EXECUTED, FILES THAT
C				  WERE QUEUED BUT NOT PRINTED WILL BE PRINTED
C				  WITH THEIR APPORPRIATE BANNERS IN THE CORRECT
C				  SEQUENCE.
C
C	** NOTE **	ACCUMULATED TIMES ARE PRINTED FOR EACH QUEUE IF /TI IS
C			SPECIFIED. THESE TIMES ARE BASED ON LP0: BEING 300LPM
C			AND AND ANY TT DEVICE (TT10 OR TT13) BEING SET AT 2400
C			BAUD.  IF A TT DEVICE IS ACTUALLY SET AT 1200 OR 4800
C			BAUD, THEN MULTIPLY OR DIVIDE THE PRINT TIME BY 2.
C
	INCLUDE 'QXCM.COM'
C
	DIMENSION ILISTS(3)
C
C	ILISTS CONTAINS THE BYTE OFFSET FROM 0 FOR THE LIST HEADS FOR
C	THE ACTIVE AND INSTALLED LISTS RESPECTIVELY
C
	DATA ILISTS/6, 4, 8/, ILUNQ/1/, NBLKS/5/
	DATA IWAC/-29/			! ** ACCESSED FOR WRITE !
	LACT = .TRUE.			! ACTIVE LIST FIRST
	LEMPTY = .TRUE.			! NO FILES QUEUED
	LPRHD = .FALSE.			! PRINT HEADING
	BENT(QFLAG) = "377		! SET ALL FLAGS FOR /FU:FILESPEC TEST
C					! MADE IN QXPC SO BANNER PAGES WON'T
C					! BE ADDED.
	BENT(QFOCO) = 1		! AND COPIES TO 1 FOR /FU:FILESPEC
	MAXDEV = 5
	CALL ERRSET (63, .TRUE., .FALSE., , .FALSE.,) ! NO CONVERSION ERRORS.
C
C	GO PARSE THE COMMAND LINE
C
	CALL QXIN
	IS = 1
	IE = 2
	IF (.NOT. LSWPD) GO TO 40
	IS = 3
	IE = 3
	LSWEC = .TRUE.
 40	CONTINUE
C
C
C	OPEN SPRQUEUE.SYS READONLY
C
 10	CONTINUE
	CALL X1LU (SPRID, SPRBUF, 5, 1, 0,
	1	ILUNQ, 'R', 'SPRQUEUE.SYS', -1, 'LB0:[1,4]', NERR)
	IF (NERR .EQ. 0) GO TO 50
	IF (NERR .EQ. IWAC) GO TO 10
	WRITE (5, 510) NERR
 510	FORMAT ('** ERROR ** OPENING SPRQUEUE.SYS, NERR =',I4)
	CALL EXIT
C
 50	CONTINUE
C
C
C	GO PROCESS THE QUEUE LISTS
C
	DO 200 I=IS, IE
	NR = ILISTS(I)/2 + 1
	CALL X1DR (SPRID, NR, 1, NEXTAD)
	ILEV = 1
C
 100	CONTINUE
	CALL QXNXE (LEOL)
	IF (LEOL) GO TO 190
	CALL QXLI
	GO TO 100
C
 190	LACT = .FALSE.
 200	CONTINUE
C
	CALL X1EF (SPRID)
C
C	PRINT OUT TOTAL PRINT WAIT TIMES IF /FU SPECIFIED
C
	IF (LSWTI) CALL QXLIT
C
C	WAS THE QUEUE EMPTY ?
C
	IF (LEMPTY) WRITE (5, 520)
 520	FORMAT (/' QX -- NO FILES QUEUED')
	WRITE (5, 525)
 525	FORMAT (/)
C
C
	END
