2!		PROGRAM		: BATIDL.BAS
5!		VERSION		: V10.1
6!		EDIT		: A
7!		EDIT DATE	: 10-MAY-91
8!
10		EXTEND
11	! &
	! &
	! &
	!		  C O P Y R I G H T &
  !	&
  !	&
  !		      Copyright (C) 1976, 1991 by &
  !	        Digital Equipment Corporation, Maynard, Mass. &
  !	&
  !	&
  !	This software is furnished under a license and may be used and &
  !	copied  only  in accordance with the terms of such license and &
  !	with the  inclusion  of  the  above  copyright  notice.   This &
  !	software  or  any  other copies thereof may not be provided or &
  !	otherwise made available to any other person.  No title to and &
  !	ownership of the software is hereby transferred. &
  !	&
  !	The information in this software is subject to change  without &
  !	notice  and should not be construed as a commitment by Digital &
  !	Equipment Corporation. &
  !	&
  !	DIGITAL assumes no responsibility for the use  or  reliability &
  !	of its software on equipment that is not supplied by DIGITAL. &
  !	&
  !*******************************************************************
20	! &
	! &
	! &
	!	M O D I F I C A T I O N    H I S T O R Y &
	&
	&

21	! VER/ED	EDIT DATE	REASON &
	! &
	&
	&
	&
	&

100	! &
	! &
	! &
	!	G E N E R A L    D E S C R I P T I O N &
	! &
	! &
	! &
	! THIS PROGRAM IS THE IDLE LOOP FOR THE BATCH PACKAGE.  ITS &
	! PURPOSE IS TO WAIT UNTIL A JOB IS READY TO GO, AND TO SET UP &
	! THE DEFAULTS FOR THAT JOB.  IT THEN CHAINS OFF THE TO &
	! BATDEC AND BATRUN PROGRAMS TO DO THE ACTUAL OUTPUT. &
	&

300	! &
	! &
	! &
	!	I / O    C H A N N E L S &
!	&
!	&
!	&
!	CHANNEL #		USED FOR &
!	   1			WORK FILE FOR BATCH UNIT. &

400	! &
	! &
	! &
	!	V A R I A B L E    D E F I N I T I O N S &
!	&
!	&
!	&
!	NAME		USED FOR &
!	A$		ACCOUNT NUMBER. &
!	A%		ACCOUNT NUMBER. &
!	B0%		FREE LIST POINTER. &
!	C$		GENERAL COMMAND DECODE STRING. &
!	C8$		BELL &
!	C9$		'CRLF' &
!	C%()		PROGRAM STATUS ARRAY. &
!	C()		PROGRAM STATUS ARRAY. &
!	E%		ERROR VARIABLE. &
!	E0%		ENTRY TYPE. &
!	FATAL.ERR%	SOME FATAL ERROR HAS BEEN DETECTED IN PACKAGE. &
!	F1%		EVENT WORD. &
!	I$		VERSION-EDIT. &
!	J$		JOB NUMBER. &
!	J%		JOB NUMBER. &
!	J1%		JOB DATA BLOCK 1. &
!	J9%		CURRENT JOB RECORD POINTER. &
!	JOBID%		JOB ID. &
!	JOBMOD%		JOB MODIFICATION RECEIVED FLAG. &
!	K%		KB: NUMBER OF BATCH UNIT IF ATTACHED. &
!	K0%		I/O BLOCK. &
!	K1%		KB: LIST FILE FLAG. &
!	M0%()		CHANGE ARRAY. &
!	MAXUNT%		MAXIMUM UNIT NUMBER. &
!	M%()		MESSAGE LIST HEAD AND TAIL POINTER ARRAY. &
!	PKG.LOC$	DEVICE/PPN OF PACKAGE. &
!	P$		CHAIN MODULE NAME. &
!	P%		POSITION POINTER FOR COMMAND STRING. &
!	P0%		CURRENT RECORD POINTER. &
!	P1%		RECORD POINTER. &
!	PHYDHI%		PHYSICAL DEVICE DEVICE HANDLER INDEX WORD. &
!	PHYSD1%		WORD 1 OF PHYSICAL DEVICE SNAME. &
!	PHYSD2%		WORD 2 OF PHYSICAL DEVICE NAME. &
!	Q9%		DESTINATION VOLUME RECORD POINTER. &
!	R%		PACKAGE STATUS WORD. &
!	S$		MODULE NAME. &
!	S$()		STRING STACK. &
!	S9%		STRING STACK POINTER. &
!	S%()		STACK. &
!	S%		STACK POINTER. &
!	S0%		SWITCH VALUE AND SLEEP TIMER. &
!	T$		TEXT TO SEND TO OPERATOR. &
!	W$		WORK FILE NAME. &
!	W0%		POINTER TO DESTINATION VOLUME RECORD. &
!	ALL Z'S		TEMPORARY LOCAL WORK VARIABLES. &

800	! &
	! &
	! &
	!	F U N C T I O N / S U B R O U T I N E    D E S C . &
!	&
!	&
!	NAME		LINE	USE &
!	FNM0$		15000	STATUS STRING BUILDER &
!	FND0%		15300	DUMP ACCOUNTING STATISTICS. &

830	! &
	! &
	!	P A C K A G E    S U B R O U T I N E S &
	! &
	! Line		Use &
	! 20000		INITIALIZE FOR POLLINT ROUTINES &
	! 20200		SEND A MESSAGE TO QUEMAN. &
	! 20300		ONLINE TO QUEMAN. &
	! 20340		REQUEST NEW JOB FROM QUEMAN. &
	! 20360		REQUEST NEXT PACKET FROM QUEMAN. &
	! 20420		REQUEST REQUE FROM QUEMAN. &
	! 20440		TELL QUEMAN ABOUT END OF JOB. &
	! 20460		REQUEST DEFERRAL OF JOB BY QUEMAN. &
	! 20900		REQUEST A NEW JOB. &
	! 21000		POLLING ROUTINES. &
	! 23050		ENTER RECEIVER TO OPSER. &
	! 23100		SEND ONLINE TO OPSER. &
	! 23140		DELETE LAST MESSAGE TO OPSER. &
	! 23500		SEND TO OPERATOR. &
	! 23600		STORE A MESSAGE INTO THE WORK FILE. &
	! 24010		NEWJOB PACKET RECEIVED. &
	! 24100		FILE PACKET RECEIVED. &
	! 24200		ENDJOB PACKET RECEIVED. &
	! 24300		KILL JOB RECEIVED FROM QUEMAN.
840	! &
	! &
	!	P A C K A G E    F U N C T I O N S &
	! &
	! Name			Lines		Use &
	! FNR%(S$,L%)		25200-25250	Match a  keyword. &
	! FNF0%(P0%,N$,D$)	25500-25690	Apply null default or &
	!					default string to a File &
	!					Descriptor Record. &
	! FNP%(P0%,P%,S$,Y0%,Y1%) &
	!			25800-25890	Turn a filename string &
	!					into a File Descriptor &
	!					Record. &
	! FNU$(P0%,C$,Z%,Z0%)	25900-25970	Turn a File Descriptor &
	!					Record into a filename &
	!					string, with switches. &
	! FNU0$(L%)		25980-25990	Return the NUM1$ of the &
	!					low byte of L%, or &
	!					'*', if the low byte is &
	!					255. &
	! FNO%(P0%,A0%,C0%)	26000-26090	Open the file described &
	!					in (work-file) record &
	!					P0% - drops and regains &
	!					temporary privs. &
	! FNA%			26100-26130 	Get the next free-list &
	!					record. &
	! FNA0%(P0%)		26200-26230	Put record P0% back &
	!					into the free-list. &
	! FNCHNGE%(S$)		27000-27020	CHANGE THE STRING S$ &
	!					INTO THE INTEGER ARRAY &
	!					Z%(), PADDING TO 30 CHRS &
	!					WITH 0'S AND CONVERT &
	!					EACH TWO BYTES TO ONE &
	!					INTEGER IN THE ODD &
	!					WORDS. &
	! FNN%			27200-27250	RETURN THE UNSIGNED &
	!					INTEGER IN THE STRING C$ &
	!					AT POSITION P%+1%. &
	! FNPUSH%		27400		PUSH A VARIABLE ONTO &
	!					THE STACK. &
	! &
	! FNPOP%		27410		POP A VARIABLE FROM &
	!					THE STACK. &
	! FNUNPACK$		27300		UNPACK A STRING OUT OF &
	!					THE WORK FILE. &
	&
	&

900	! &
	! &
	! &
	!	D I M E N S I O N    S T A T E M E N T S &

901	DIM #1%,Z0%(32767%,63%) &
	\ DIM #1%,Z0$(32767%)=128% &
	\ DIM S%(30%) &
	&
	\ DIM M0%(30%) &
	&
	\ DIM CTLTBL%(3%),CTLTBL$(3%) &
	&
				! WORK-FILE, PRIMARY. &
				! &
				! INTERNAL STACK. &
				! &
				! M0%() - &
				! USED IN THE 'ASSIGN DEVICE' ROUTINE &
				!  AT 11000. &
				! &
				! CTLTBL%(),CTLTBL$() - &
				! USED TO HOLD THE CARRIAGE CONTROL &
				!  INFORMATION. &

950	!	DIMENSION STATEMENTS FOR STANDARD ROUTINES
951	DIM Z%(30%)		! USED BY FNP%() FOR RETURN OF DATA
952	DIM Z1%(63%)		! USED BY FNP%() FOR TEMPORARY STORAGE &
				! OF DATA.
953	DIM M%(5%)		! USED BY THE POLLING ROUTINES TO HOLD &
				!  THE HEAD AND TAIL POINTERS FOR THE &
				!  FOLLOWING LISTS : &
				!	M%(0%)	- HEAD OF INCOMPLETE &
				!		   LIST &
				!	   1%	- TAIL OF LIST &
				!	   2%	- HEAD OF COMPLETE LIST &
				!	   3%	- TAIL OF LIST &
				!	   4%	- HEAD OF UNPROCESSED &
				!		   LIST &
				!	   5%	- TAIL OF LIST &
	&
	&
	&
	&
	&
	&
	&

999	! &
	! &
	! &
	!	M A I N    C O D E &

1000	ON ERROR GOTO 19000 &
	\ UU0$=CHR$(6%)+CHR$(26%)+CHR$(0%)+CHR$(0%) &
	\ UU1$=CHR$(6%)+CHR$(26%)+CHR$(0%)+CHR$(1%) &
		! SET UP STANDARD ERROR TRAP. &

1010	I$="V10.1-A" &
	\ IF E0%=0% &
		THEN &
			PRINT "BATIDL	"+I$ &
		! SET UP HEADER LINE. &
		! PRINT THE HEADER. &

1020	CHANGE SYS(CHR$(12%)) TO Z% &
	\ PKG.LOC$="OPSER$:" &
	\ IF Z%(3%)+SWAP%(Z%(4%))<>15%*2% THEN &
		PRINT "?BATIDL must be COMPILED" &
	\	GOTO 32767 &
		! USE LOGICAL FOR PACKAGE LOCATION &
		! PRINT ERROR IF IT WAS NOT A COMPILED FILE. &

1030	IF E0%<>2% THEN &
		PRINT "?Illegal entry - Please 'RUN " + PKG.LOC$ + "BATCH'" &
	\	GOTO 32767 &
		! THE ONLY LEGAL ENTRY TO THIS PROGRAM IS A CHAIN ENTRY, &
		! SO GIVE AN ERROR IF THAT WASN'T THE WAY WE ENTERED. &

1040	S%=-1% &
		! INIT THE STACK POINTER. &

1620	S$="BATIDL	"+I$ &
	\ CHR0$=CHR$(0%) &
	\ CHR10$=CHR$(10%) &
	\ CHR12$=CHR$(12%) &
	\ CHR13$=CHR$(13%) &
	&
	\ CHR6$=CHR$(6%) &
	\ CHR7$=CHR$(7%) &
	\ CHR6.M10$=CHR6$+CHR$(-10%) &
	\ CHR6.9$=CHR6$+CHR$(9%) &
	\ CHR6.M21.M1$=CHR6$+CHR$(-21%)+CHR$(-1%) &
	\ CHR6.M21.0$=CHR6$+CHR$(-21%)+CHR0$ &
	\ CHR6.18.M1.0$=CHR6$+CHR$(18%)+CHR$(-1%)+CHR0$ &
	\ CHR192$=CHR$(128%+64%) &
	\ CVT00$=CVT%$(0%) &
	&
	\ NULSTG$="" &
	&
	&
		! HOLD THE DEVICE HANDLER FLAG WORD, THE DEVICE SWITCH &
		!  SPECIFICATION WORD, AND THE DEVICE CHARACTERISTICS &
		!  WORD. &

1700	GOSUB 20000 &
	\ PHYDHI%=Z0%(Q9%,13%) &
	\ DSSW%=Z0%(Q9%,34%) &
	\ DCW%=Z0%(Q9%,17%) &

2000	! &
	! &
	! &
	!	I D L E    L O O P &

2010	W0%=Z0%(Q9%,23%) &
	\ W1%=Z0%(Q9%,24%) &
		! SET UP A POINTER TO THE DESTINATION VOLUME RECORD; &
		! HOLD THE FORM NAME OF THE CURRENT FORM. &

2020	GOTO 9000 IF FATAL.ERR% &
	\ GOTO 4000 IF (R% AND 8%) &
	\ R%=R% AND -17% &
	\ F1%=2% \ S0%=-1% \ GOSUB 20900 &
	\ GOTO 9000 IF (R% AND 64%) &
	\ GOTO 3000 IF (R% AND 128%) &
	\ GOTO 2020 &
		! GO PROCESS THE ENDJOB, IF THE STATUS INDICATES THAT IT &
		!  IS NEEDED; &
		! GO DO AN 'OFFLINE TO QUEMAN' IF THE 'OFFLINE TO &
		!  QUEMAN' FLAG IS SET; &
		! MAKE SURE THE 'OFFLINE TO QUEMAN' IS RESET; &
		! SET THE FOLLOWING EVENTS : &
		!	SOME NON-JOB CHANGE OCCURRED (EG, JOB READY, &
		!	 'END', 'FORMS') &
		! SET AN INFINITE SLEEP TIME; &
		! GET A NEW JOB; &
		! DISPATCH TO 9000 FOR AN 'END' REQUEST; &
		! DISPATCH TO 8000 FOR A 'FORMS CHANGE' REQUEST; &
		! OTHERWISE, IT MUST BE A JOB, SO GO PROCESS IT; &
		! GO BACK FOR MORE. &
	&
	&
	&

3000	! &
	! &
	! &
	!	G O T    A    N E W    J O B &
	!	A P P L Y    D E F A U L T S &

3010	J9%=FND0%(Z0%(Q9%,8%)) &
	\ J9%=Z0%(0%,27%) &
	\ R0%=Z0%(J9%,31%) &
	\ R%=(R% AND -129%) OR 1% &
	\ Z%(Z%)=Z0%(Q9%,Z%) FOR Z%=6% TO 30% &
	\ Z1%(Z%)=Z0%(J9%,Z%) FOR Z%=1% TO 63% &
	\ Z1%(6%)=Z%(9%) \ Z1%(7%)=Z%(10%) &
	\ R1%=Z0%(J9%,34%) &
		! DUMP THE CURRENT STATISTICS TO THE DEFAULT ACCOUNT; &
		! SET UP THE ADDRESS OF THE JOB RECORD IN THE JOB &
		!  POINTER; &
		! RESET THE 'JOB READY' FLAG AND SET THE 'JOB IN &
		!  PROCESS' FLAG; &
		! HOLD THE DEFAULT INFORMATION FROM THE DESTINATION &
		!  DEVICE RECORD; &
		! SET UP THE DESTINATION DEVICE IN THE JOB RECORD; &
		! HOLD THE SWITCH SPECIFICATION WORD FOR THE JOB; &

3030	IF (R0% AND 16384%) THEN &
		Z%(Z%)=Z0%(J9%,Z%+54%) FOR Z%=1% TO 5% &
	\	Z1%(37%)=Z%(1%) &
	\	Z%=Z1%(2%) &
	\	Z1%=Z%(2%) &
	\	Z%=Z0%(Z%,1%) FOR Z0%=1% WHILE Z% AND Z0%<Z%(2%) IF Z1% &
	\	GOTO 3900 UNLESS Z% IF Z1% &
	\	Z0%(Z%,37%)=Z%(3%) &
	\	Z0%(Z%,58%)=Z%(4%) &
	\	Z0%(Z%,59%)=Z%(5%) &
	\	Z0%(Z%,60%)=32767% &
	\	Z0%(Z%,31%)=Z0%(Z%,31%) OR 2% &
	\	Z1%(27%)=Z% &
		! IF THE 'REQUE IN PROGRESS' FLAG IS SET ON THE JOB, &
		!  THEN &
		!	HOLD THE 5 REQUE WORDS OUT OF THE JOB RECORD; &
		!	PUT IN THE 'JOB COPY NUMBER' FROM THE REQUE &
		!	 INFO; &
		!	SEARCH FOR THE FILE WHOSE ORDINAL POSITION IN &
		!	 JOB'S FILE LIST MATCHES THAT SPECIFIED IN THE &
		!	 REQUE INFO; &
		!	GO ISSUE ERROR IF NONE MATCH (SOMEBODY &
		!	 DELETED A FILE SINCE THE REQUE); &
		!	OTHERWISE, SET UP THE FILE COPY NUMBER OUT OF &
		!	 THE REQUE INFO; &
		!	SET UP THE 'RESTART BLOCK', 'RESTART BYTE', &
		!	 AND 'RESTART PAGE' VALUES OUT OF THE REQUE &
		!	 INFO; &
		!	SET THE 'RESTART IN PROGRESS' FLAG ON THE FILE; &
		!	FINALLY, LOAD THE CARDINAL NUMBER OF THE FILE &
		!	 (IE, THE FILE'S ADDRESS IN THE WORK-FILE) INTO &
		!	 THE JOB RECORD FOR THE JOB. &

3090	JOBID%,Z0%(0%,36%)=Z0%(0%,36%)+1% &
	\ Z1%(36%)=JOBID% &
	\ Z0%(J9%,Z%)=Z1%(Z%) FOR Z%=6% TO 63% &
	\ R%=R% OR 1% &
	&
	\ Z%,Z0%(J9%,38%)=FNA% &
	\ Z$="["+NUM1$(SWAP%(Z0%(J9%,8%)) AND 255%)+","+ &
		NUM1$(Z0%(J9%,8%) AND 255%)+ &
		"]"+RAD$(Z0%(J9%,9%))+RAD$(Z0%(J9%,10%))+".LOG" &
	\ Z%=FNP%(Z%,0%,Z$,0%,0%) &
	\ ASSGN0%=(Z0%(Q9%,17%)>=0%) &
	\ T$="WAITING FOR "+FNU$(Q9%,NULSTG$,4096%,0%) &
	\ UNTIL ASSGN0%=0% &
	\	S0%=0% \ GOSUB 11000 \  F1%=1% &
	\	S0%=15% AND ASSGN0%<>0% \ GOSUB 21000 &
	\ NEXT &
	\ T$=NULSTG$ &
	&
		! INCREMENT THE JOB COUNT FOR THIS RUN; &
		! MAKE THE ID OF THIS JOB THE CURRENT JOB COUNT IF THE &
		!  JOB DID NOT COME FROM THE QUEUE; &
		! LOAD ALL THE DEFAULTED/REQUE'D INFO BACK INTO THE REAL &
		!  JOB RECORD IN THE WORK-FILE; &
	&
		! DO AN ASSIGNMENT LOOP IF THE DEVICE IS NOT ALREADY &
		!  ASSIGNED. &
	&
		! SET 'JOB IN PROCESS' IN PACKAGE. &

3800	! &
	! &
	! &
	!	S E T    U P    C H A I N    L I S T &
	&

3810	P0%=Z0%(0%,14%) &
	\ Z%=FNPUSH%(P1%) &
	\ P1%=FNPUSH%(FNA%) &
	\ WHILE P0% &
	\	Z$=Z0$(P0%) &
	\	Z0$(P1%)=Z$ &
	\	P0%=Z0%(P0%,1%) &
	\	P1%,Z0%(P1%,1%)=FNA% IF P0% &
	\ NEXT &
	\ Z%=Z0%(0%,13%) \ Z0%(0%,13%)=FNPOP% &
	\ Z0%(P1%,1%)=Z% &
	\ P1%=FNPOP% &
		! HOLD THE POINTER TO THE CHAIN LIST TO COPY; &
		! HOLD THE ADDRESS OF A FREE RECORD TO FILL; &
		! WHILE ANY EXIST IN THE COPY LIST : &
		!	COPY IT; &
		!	MOVE TO NEXT; &
		! LOOP; &
		! PUT THE FIRST RECORD'S ADDRESS INTO THE CHAIN LIST &
		!  POINTER IN THE FHR; &
		! RESTORE OLD VALUE OF WORK RECORD ADDRESS. &
	&

3890	GOTO 9000 &
	&
	&

3900	! &
	! &
	! &
	!	E R R O R    R O U T I N E    F O R    T H E &
	!	R E Q U E / R E S T A R T    O P E R A T I O N &
	&

3910	T$=FNM0$("ERROR IN RESTART FROM REQUE",J9%,0%,0%,0%)+C9$+ &
		"FILE NUMBER OUT OF BOUNDS"+C9$+"JOB ABORTED" &
	\ GOSUB 23500 &
	\ R%=R% OR 8% &
	\ R0%,Z0%(J9%,31%)=R0% OR 1% &
	\ GOTO 2000 &
		! SET UP AND ISSUE AN ERROR MESSAGE DESCRIBING THE &
		!  PROBLEM; &
		! SET THE 'ENDJOB NEEDED' FLAG AND GO BACK TO THE IDLE &
		!  LOOP; &
		! SET THE 'JOB ABORTED' FLAG IN THE PRW OF THE JOB &
		!  RECORD (THIS WILL CAUSE THE 'ENDJOB' ROUTINE TO ISSUE &
		!  A 'RESTART' REQUEST TO QUEMAN BEFORE THE 'ENDJOB' &
		!  REQUEST, IF THE JOB CAME FROM THE QUEUE). &
	&
	&
	&

4000	! &
	! &
	! &
	!	E N D    O F    J O B    P R O C E S S I N G &
	&

4010	J9%=Z0%(0%,27%) &
	\ GOTO 4090 UNLESS J9% &
	\ IF Z0%(J9%,17%)=2% AND (Z0%(J9%,31%) AND 4%) THEN &
		Z1%(Z%)=0% FOR Z%=55% TO 60% &
	\	Z1%(55%)=Z0%(J9%,37%) &
	\	P0%=Z0%(J9%,27%) &
	\	WHILE P0% &
	\		Z0%=Z0%(J9%,2%) &
	\		Z0%=Z0%(Z0%,1%) FOR Z%=1% WHILE Z0% AND Z0%<>P0% &
	\		Z1%(56%)=Z% AND Z0%<>0% &
	\	 	Z1%(57%)=Z0%(P0%,37%) &
	\		Z1%(Z%)=Z0%(P0%,Z%) FOR Z%=58% TO 60% &
	\		Z1%(57%)=Z0%(P0%,37%) &
	\		P0%=0% &
	\	NEXT &
	\	Z0%(J9%,Z%)=Z1%(Z%) FOR Z%=55% TO 60% &

4020	IF Z0%(J9%,17%)=2% THEN &
		IF (R% AND 8192%) THEN &
			R0%=Z0%(J9%,31%) &
	\		GOSUB 20400 IF (R0% AND 15%) &
	\		GOSUB 20420 IF (R0% AND 4%) &
	\		GOSUB 20460 IF (R0% AND 8%) &
	\		GOSUB 20440 &
		! SET UP THE ADDRESS OF THE JOB RECORD INTO THE JOB &
		!  POINTER; &
		! GO TO THE EXIT IF THE JOB ADDRESS IS 0; &
		! OTHERWISE, IF THE 'SOURCE' OF THE JOB IS THE QUEUE, &
		!  THEN &
		!	IF THE PACKAGE IS STILL ONLINE TO QUEMAN, THEN &
		!		HOLD THE JOB'S PRW; &
		!		DO THE APPROPRIATE 'SENDS' TO QUEMAN : &
		!			'RESTART' IF ANY OF 'ABORT', &
		!			 'REQUE', 'DEFER', OR 'RESTART'; &
		!			'REQUE' IF REQ.; &
		!			'DEFER' IF REQ.; &
		!			'ENDJOB', ALWAYS. &

4070	GOSUB 11100 UNLESS Z0%(Q9%,17%)<0% &
	\ Z%=FND0%(Z0%(J9%,8%)) &
	&
	\ Z1%=0% \ Z%=Z0%(0%,2%) &
	\ WHILE Z%<>J9% AND Z% &
	\	Z1%=Z% &
	\	Z%=Z0%(Z%,1%) &
	\ NEXT &
	\ IF Z%=J9% THEN &
		IF Z1%=0% THEN &
			Z0%(0%,2%)=Z0%(J9%,1%) &
		ELSE	Z0%(Z1%,1%)=Z0%(J9%,1%) &
	&
		! DEASSIGN THE OUTPUT DEVICE, IF NOT ASSIGNED &
		!  PERMANENTLY; &
		! DUMP THE STATISTICS FOR THE JOB TO THE JOB'S ACCOUNT. &
		! &
		! NEXT, SEARCH FOR THE RECORD BEFORE THIS JOB RECORD; &
		! IF ONE IS FOUND, THEN &
		!	UPDATE ITS POINTER TO POINT TO THE RECORD AFTER &
		!	 THE ONE TO BE TAKEN OUT. &

4090	J9%=FNA0%(J9%) IF J9% &
	\ R%=R% AND -10% &
	\ GOTO 2000 &
		! RETURN THE JOB RECORD TO THE FREE LIST; &
		! RESET THE 'IN A JOB' AND 'END JOB NEEDED' FLAGS; &
		! GO BACK TO THE IDLE LOOP. &
	&

9000	! &
	! &
	! &
	!	C L O S E O U T    A N D    E X I T &
	&

9010	Z0%(0%,11%)=FNA0%(Z0%(0%,11%)) IF Z0%(0%,11%) &
	\ P0%=Z0%(0%,13%) &
	\ IF P0% THEN &
		P$=FNU$(P0%,NULSTG$,-1%,0%) &
	\	Z0%(0%,13%)=Z0%(P0%,1%) &
	\	Z0%(P0%,1%)=0% &
	\	Z%=FNA0%(P0%) &
		! GET RID OF THE INDIRECT COMMAND LIST; &
		! SET UP THE NEXT ONE TO CHAIN TO IF ONE IS IN THE LIST. &

9020	WHILE M%(4%) &
	\	Z0%(M%(5%),1%)=M%(2%) &
	\	Z0%(M%(2%),0%)=M%(5%) IF M%(2%) &
	\	M%(2%)=M%(4%) &
	\	M%(4%)=0% &
	\ NEXT &
	\ Z0%(0%,9%)=M%(2%) &
	\ Z0%(0%,19%)=M%(0%) &
	&
	\ Z0%(0%,0%)=B0% &
	\ Z0%(0%,26%)=R% &
	\ Z0%(0%,27%)=J9% &
	\ Z0%(0%,49%)=FATAL.ERR% &
	&
	\ W$=SYS(CHR$(8%)+CVT00$+FNU$(Z0%(0%,12%),NULSTG$,-1%, &
		-1%)) IF P0% &
	\ CLOSE Z% FOR Z% = 1% TO 12% &
	\ ON ERROR GOTO 19000 &
	\ IF P0% THEN &
		CHAIN P$ LINE 31000% + (32767%+1%) &
	  ELSE	STOP &
	\	GOTO 32767 &
	&
		! THIS LINE PLACES THE HEAD POINTERS OF THE COMPLETE &
		!  MESSAGE AND INCOMPLETE MESSAGE LISTS INTO THE WORK- &
		!  FILE FOR RETRIEVAL BY THE NEXT MODULE.  IF ANY &
		!  'UNPROCESSED' REQUESTS ARE PRESENT, THEY ARE PUT AT &
		!  THE FRONT OF THE 'COMPLETED' MESSAGES LIST. &
		! &
		! REPLACE THE FREE-LIST POINTER, THE PACKAGE STATUS, AND &
		!  THE CURRENT JOB NUMBER IN THE FILE HEADER RECORD. &
		! &
		! PUT THE WORK-FILE NAME INTO CORE COMMON IF A CHAIN IS &
		!  TO BE DONE; &
		! CLOSE THE FILES; &
		! IF THERE WAS A CHAIN RECORD, THEN &
		!	DO THE CHAIN; &
		! ELSE	GO DO THE FINAL CLOSE OUT. &
	&
	&
	&
	&

11000	! &
	! &
	! &
	!	A S S I G N    T H E    D E V I C E &
	&

11010	MAXUNT%=64% UNLESS MAXUNT% &
	\ WHILE PHYSD1%=0% &
	\	PHYSD1%=Z0%(Q9%,6%) \ PHYSD2%=Z0%(Q9%,7%) &
	\	PHYDHI%=Z0%(Q9%,13%) &
	\ NEXT &
	\ CHANGE SYS(CHR6.M10$+RAD$(PHYSD1%)+RAD$(PHYSD2%)+ &
		":") TO M0% &
	\ M0%(0%)=30% \ M0%(1%)=6% \ M0%(2%)=10% &
	\	M0%(Z%)=0% FOR Z%=3% TO 22% &
	\	M0%(Z%)=0% FOR Z%=27% TO 30% &
		! SET UP A MAXIMUM UNIT NUMBER (DEFAULT IS FOR KB:); &
		! SET UP THE VARIABLES TO HOLD THE PHYSICAL DEVICE INFO, &
		!  IF THEY ARE NOT ALREADY SET UP; &
		! DO AN FSS ON THE DEVICE NAME TO GET IT INTO A &
		!  CONVENIENT FORM FOR THE 'ASSIGN' CALL; &
		! PLUG IN THE 'ASSIGN' CALL VALUES. &

11020	IF (PHYDHI% AND 16384%) THEN &
		UNITNO%=M0%(25%) &
	ELSE	M0%(26%)=-1% &
	\	Z%=FNPUSH%(S0%) \ S0%=0% &
	\	GOSUB 11030 FOR UNITNO%=0% WHILE ASSGN0% AND &
			UNITNO%<MAXUNT% AND E%=0% &
	\	S0%=FNPOP% &
	\	MAXUNT%=UNITNO% IF E%=6% &
	\	E%=0% IF E%=6% &
	\	GOTO 11040 &
		! IF AN ABSOLUTE DEVICE IS SPECIFIED, THEN &
		!	SET UP THE UNIT NUMBER AND DROP THROUGH TO &
		!	 ASSIGN; &
		! ELSE	SET THE UNIT NUMBER FLAG, SO THE ASSIGN FINDS &
		!	 ONE THERE; &
		!	PUSH THE SLEEP FLAG, SO THE SUBSEQUENT ROUTINE &
		!	 WILL NOT SLEEP; &
		!	CALL THE ASSIGN ROUTINE FOR EACH POSSIBLE UNIT, &
		!	 UNTIL EITHER THE ASSIGNMENT IS PERFORMED, THE &
		!	 MAXIMUM DEVICE HAS BEEN FOUND, OR SOME ERROR &
		!	 OCCURRED; &
		!	POP THE SLEEP FLAG IMMEDIATELY; &
		!	SET THE ACTUAL MAXIMUM COUNT IF THE ERROR MEANT &
		!	 THAT THAT HAD BEEN FOUND; &
		!	RESET THE ERROR IF IT MEANT MAX COUNT; &
		!	GOTO THE EXIT ROUTINE. &

11030	ON ERROR GOTO 11070 &
	\ M0%(25%)=UNITNO% &
	\ CHANGE M0% TO Z$ &
	\ Z$=SYS(Z$) &
	\ ASSGN0%=0% &
	\ Z%=FNCHNGE%(SYS(CHR6.M10$+CHR$(M0%(23%))+CHR$(M0%(24%))+ &
	    NUM1$(UNITNO%))) &
	\ PHYSD1%=Z%(7%) \ PHYSD2%=Z%(9%) &
	\	PHYDHI%=PHYDHI% OR 16384% &
	\ Z0%(Q9%,6%)=PHYSD1% \ Z0%(Q9%,7%)=PHYSD2% &
		! SET UP THE ERROR TRAP; &
		! PLUG IN THE UNIT NUMBER; &
		! DO THE 'ASSIGN' CALL; &
		! SUCCESS : &
		! RESET THE 'ASSIGNMENT NECESSARY' FLAG; &
		! SET UP THE PHYSICAL DEVICE NAME IN THE PROPER FLAG &
		!  WORDS AND BACK INTO THE DESTINATION VOLUME RECORD. &

11040	IF ASSGN0%=0% OR E% THEN &
		GOTO 11050 &
	ELSE	IF S0%=0% THEN &
			GOTO 11050 &
		ELSE	SLEEP 30% &
	\		GOTO 11020 &
		! IF THE ASSIGNMENT WAS SUCCESSFUL OR AN UNEXPECTED &
		!  ERROR OCCURRED, THEN &
		!	GOTO EXIT; &
		! ELSE	IF THE SLEEP TIME IS 0, THEN &
		!		GOTO EXIT; &
		!	ELSE	SLEEP AWHILE; &
		!		GO TRY THE ASSIGNMENT LOOP AGAIN. &

11050	ON ERROR GOTO 19000 &
	&
	\ RETURN &
	&
		! RESET ERROR TRAP. &
	&
		! AND EXIT. &

11070	! &
	!	ERROR HANDLER FOR THE ASSIGNMENT ROUTINE &

11080	E%=ERR \ RESUME 11090 &
		! HOLD THE ERR VALUE AND MAKE SURE OF THE RESUME. &

11090	IF E%<>8% THEN &
		GOTO 11050 &
	ELSE	E%=0% &
	\	GOTO 11040 &
		! IF THE ERROR IS NOT DEVICE NOT AVAILABLE, THEN &
		!	EXIT; &
		! ELSE	RESET THE ERROR AND GO TO THE EXIT ROUTINE. &
	&

11100	! &
	! &
	! &
	!	D E A S S I G N    P R I N T E R &
	&

11110	CHANGE SYS(CHR6.M10$+FNU$(Q9%,NULSTG$,4096%,0%)) TO &
		Z% &
	\ Z%(0%)=30% \ Z%(1%)=6% \ Z%(2%)=11% &
	\ Z%(Z%)=0% FOR Z%=3% TO 22% &
	\ Z%(Z%)=0% FOR Z%=27% TO 30% &
	&
	\ CHANGE Z% TO Z$ &
	\ Z$=SYS(Z$) &
	&
	\ IF (Z0%(Q9%,13%) AND 16384%)=0% THEN &
		Z%=FNCHNGE%(SYS(CHR6.M10$+CHR$(Z%(23%))+ &
		   CHR$(Z%(24%)))) &
	\	Z0%(Q9%,6%)=Z%(7%) &
	\	Z0%(Q9%,7%)=0% &
		! DO THE DEASSIGN; &
		! IF THE DEVICE DID NOT ORIGINALLY HAVE A UNIT NUMBER &
		!  WITH IT, MAKE SURE THAT THE UNIT NUMBER IS NOT KEPT. &

11120	RETURN &
		! AND EXIT. &
	&

15000	DEF* FNM0$(T$,J9%,P0%,E%,PGEFLG%) &

15010	T$=T$+" - " IF T$<>NULSTG$ &
	\ IF J9% THEN &
		T$=T$+" JOB : "+FNU$(J9%,NULSTG$,129%,0%) &
	\	IF P0% THEN &
			T$=T$+"	FILE - "+FNU$(P0%,NULSTG$,-1%,0%) &
	\		IF PGECNT% THEN &
				T$=T$+C9$ &
	\			T$=T$+"PAGE : "+NUM1$(PGECNT%)+ &
				 "	" IF PGEFLG% &
	\			T$=T$+"BLOCK : "+NUM1$(BLKCNT%) &

15090	T$=T$+C9$+ &
		CVT$$(RIGHT(SYS(CHR6.9$+CHR$(E%)),2%), &
			4%) IF E% &
	&
	\ FNM0$=T$ &
	&
	\ FNEND &
		! AND EXIT. &
	&

15300	DEF* FND0%(A%) &
	\ ON ERROR GOTO 15314 &
	! FUNCTION :	FND0%	DUMP CURRENT STATISTICS TO ACCOUNT IN A% &
	&

15310	Z%(0%)=30% \ Z%(1%)=6% \ Z%(2%)=-15% &
	\ Z%(Z%)=0% FOR Z%=3% TO 30% &
	\ Z%(5%)=A% \ Z%(6%)=SWAP%(A%) &
	\ CHANGE Z% TO Z$ &
	\ Z$=SYS(Z$) &
	\ FND0%=0% &
	\ GOTO 15316 &

15314	RESUME 15316 &

15316	ON ERROR GOTO 19000 &

15320	FNEND &
	&

19000	! &
	! &
	! &
	!	U N E X P E C T E D    O R    U N R E C O V E R A B L E &
	!		E R R O R    H A N D L E R &
	&

19005	IF ERL=19990% THEN &
	   T$="FATAL ERROR WHILE NO ACCESS TO WORK-FILE: ERR=" &
	     +NUM1$(E%)+" ERL="+NUM1$(E1%) &
	\  PRINT T$ &
	\  STOP &
	!  PUT THE JOB INTO HIBERNATION WHILE THE JOB IS DETACHED &

19010	E%=ERR \ E1%=ERL \ RESUME 19020 &
		! SET UP THE ERROR VALUE AND LINE; &
		! MAKE SURE OF THE RESUME. &

19020	ON ERROR GOTO 19000 &
		! RESET ERROR TRAP. &

19990	FATAL.ERR%=ERR &
	\ Z0%(0%,50%)=ERL &
	\ Z0%(0%,51%)=3260% &
	\ Z0%(0%,52%)=14572% &
	\ Z$=SYS(CHR6.M10$+MID(I$,2%,3%)+RIGHT(I$,6%)) &
	\ Z0%(0%,53%)=CVT$%(MID(Z$,7%,2%)) &
	\ Z0%(0%,54%)=CVT$%(MID(Z$,9%,2%)) &
	\ GOTO 2000 &
		! PACK IN FATAL ERROR DATA INTO WORK FILE AND GET OUT. &
	&

20000	! &
	! &
	! &
	!	I N I T I A L I Z E    F O R    P O L L I N G &
	!	R O U T I N E    A N D    M S G    S T O R A G E &
	&

20010	! Z$=SYS(CHR6.M21.M1$) &
		OPEN W$ FOR INPUT AS FILE 1% &
	! \	Z$=SYS(CHR6.M21.0$) &
	\ R%=Z0%(0%,26%) &
	\ B0%=Z0%(0%,0%) &
	\ J9%=Z0%(0%,27%) &
	\ Q9%=Z0%(0%,4%) &
	\ FATAL.ERR%=Z0%(0%,49%) &
	\ NOT32767%=NOT 32767% &
	&
	\ M%(0%)=Z0%(0%,19%) &
	\ M%(2%)=Z0%(0%,9%) &
	\ FOR Z%=0% TO 2% STEP 2% &
	\	Z0%=M%(Z%) &
	\	IF Z0% THEN &
			Z0%=Z0%(Z0%,1%) WHILE Z0%(Z0%,1%) &
	\		M%(Z%+1%)=Z0%
20020	  NEXT Z% &
	&
	\ J%=(PEEK(518%) AND 255%)/2% &
	\ J$="  " \ RSET J$=NUM1$(J%) &
	\ J1%=SWAP%(CVT$%(MID(SYS(UU1$),25%,2%))) &
	\ A%=SWAP%(CVT$%(MID(SYS(UU0$),21%,2%))) &
	\ Z$="   " \ RSET Z$=NUM1$(SWAP%(A%) AND 255%) &
	\	A$="["+Z$ \ RSET Z$=NUM1$(A% AND 255%) &
	\	A$=A$+","+Z$+"]" &
	\ K0%=PEEK(J1%) &
	\ K%=(SWAP%(PEEK(PEEK(K0%)+2%)) AND 255%) OR &
		(R% AND 16384%)=0% &
	&
	\ C8$=CHR7$ &
	\ C9$=CHR13$+CHR10$ &
	\ GOSUB 23050 IF (R% AND 2048%) &
	\ GOSUB 23100 IF (R% AND 4096%) &
	\ GOSUB 20300 IF (R% AND 8192%) &
	&
	\ RETURN &
	&
		! DROP PRIVILEGES, (TRY TO) OPEN THE WORK-FILE, AND &
		!  REGAIN PRIVILEGES; &
		! GET THE STATUS WORD OUT OF THE WORK-FILE; &
		! GET THE (WORK-FILE) FREE-LIST POINTER, THE CURRENT JOB &
		!  POINTER, AND THE OUTPUT VOLUME POINTER INTO SOME &
		!  CONVENIENT (IN-MEMORY) VARIABLES. &
	&
		! THESE TWO LINES SET UP THE HEADS AND TAILS OF THE &
		!  INCOMPLETE MESSAGES AND COMPLETED MESSAGES LISTS. &
		!  THE HEADS OF THE LISTS ARE TAKEN DIRECTLY OUT OF THE &
		!  FILE HEADER RECORD OF THE WORK-FILE; THE TAILS MUST &
		!  BE FOUND BY A SCAN, IF THE LISTS ARE NON-EMPTY. &
	&
		! SET UP PARAMETERS FROM THE EXEC : &
		!	GET THE JOB NUMBER INTO J%; &
		!	SET UP A JOB NUMBER STRING IN J$; &
		!	GET THE ACCOUNT NUMBER OF THIS JOB OUT OF THE &
		!	 JDB OF THE JOB; &
		!	TURN THE ACCOUNT NUMBER INTO AN ACCOUNT NUMBER &
		!	 STRING; &
		!	STORE IN K0% THE ADDRESS OF THE I/O BLOCK FOR &
		!	 THIS JOB, FOR LOOKING UP SUCH THINGS AS THE &
		!	 CURRENT KEYBOARD, FOR ATTACHED/DETACHED, OR THE &
		!	 STATUS OF AN OPEN CHANNEL; &
		!	AND SET UP THE KEYBOARD NUMBER OF THIS JOB'S &
		!	 KEYBOARD, UNLESS THE STATUS FLAG SHOWS THAT &
		!	 THE JOB IS DETACHED. &
	&
		! SET UP TWO USEFUL STRING CONSTANTS : &
		!	C8$	- A ^G (<BELL>) CHARACTER, FOR &
		!		   NOTIFICATION STRINGS &
		!	C9$	- A <CR><LF> STRING FOR GENERAL USE &
		! CALL THE 'ENTER' ROUTINE IF THE JOB IS ENTERED; &
		! CALL THE 'ONLINE' ROUTINE IF THE JOB IS ONLINE TO &
		!  OPSER; &
		! CALL THE 'ONLINE TO QUEMAN' ROUTINE IF THE JOB IS &
		!  ONLINE TO QUEMAN; &
		! THESE THREE ROUTINES, ENTER, ONLINE, AND ONQUE, SET &
		!  UP APPROPRIATE CONSTANTS AND STRINGS TO DO THE &
		!  REQUIRED POLLING AND COMMUNICATIONS. &
		! &
		! AND EXIT. &
	&

20200	! &
	! &
	! &
	!	S E N D    A    M E S S A G E    T O    Q U E M A N &
	&

20210	Z%=FNPUSH%(P%) \ P%=0% &
	\ R8%=0% &
		! PUSH THE CURRENT VALUE OF P% FOR &
		!  RECOVERY LATER; &
		! RESET THE RETRY COUNTER. &

20220	ON ERROR GOTO 20240 &
	\ WHILE P%<LEN(T$) &
	\	Z%=LEN(T$)-P%+1% &
	\	Z%=255% IF Z%>19% &
	\	Z$=SYS(Q1$+CHR$(Z%)+RIGHT(T$,P%+1%)) &
	\	R8%=0% &
	\	P%=P%+19% &
	\ NEXT &
	\ R%=R% OR 8192% &
		! RESET THE RETRY COUNTER; &
		! SEND EACH PART OF THE MESSAGE; &
		! SET THE 'ONLINE TO QUEMAN' FLAG. &

20230	P%=FNPOP% &
	\ ON ERROR GOTO 19000 &
	\ RETURN &
		! POP THE OLD VALUE OF P%; &
		! RESET THE TRAP; &
		! EXIT. &

20240	IF ERR=32% THEN &
		R8%=R8%+1% &
	\	IF R8%<60% THEN &
			SLEEP 5% &
	\		RESUME 20220 &
		! IF THE ERROR WAS 'NO ROOM', THEN &
		!	(IT'S PROBABLY A TEMPORARY CONDITION, SO) &
		!	INCREMENT THE RETRY COUNTER; &
		!	IF IT IS STILL LESS THAN 60, THEN &
		!		SLEEP AWHILE AND TRY AGAIN &
		!	(ELSE	QUEMAN HAS BEEN HUNG TOO LONG - &
		!		 SO FATAL). &

20250	T$="***** QUEMAN HUNG *****" \ GOSUB 23500 &
	\ RESUME 20230 &
		! SOME OTHER ERROR - ISSUE MESSAGE. &
	&

20300	! &
	! &
	! &
	!	O N L I N E    T O    Q U E M A N &
	&

20310	Q1$=CHR6.18.M1.0$+ &
	 MID(SYS(CHR6.M10$+"QUEMAN"),7%,4%) &
	\ RETURN IF (R% AND 8192%) &
	\ T$=CHR$(5%)+CHR7$+LEFT(RAD$(Z0%(Q9%,9%)),2%)+ &
		CHR$(Z0%(Q9%,11%))+CVT%$(SWAP%(Z0%(0%,23%)))+ &
		CVT%$(SWAP%(Z0%(0%,24%)))+CHR$(1%) &
	\ GOSUB 20200 &
	\ GOTO 20380 &
		! SET UP THE 'SEND TO QUEMAN' STRING, REGARDLESS &
		!  OF WHETHER OR NOT THE ONLINE HAS ALREADY BEEN &
		!  SENT; &
		! ESCAPE IF IT HAS; &
		! OTHERWISE, SET UP A STRING OF THE FORM : &
		!	(5)(LEN OF SUBPACKET)(QUEUE NAME) &
		!	  (QUEUE UNIT)(LOGICAL ID)(1) &
		! SEND THIS STRING TO QUEMAN; &
		! GO DO A 'FORMS' REQUEST. &
	&
	&
	&

20340	! &
	! &
	! &
	!	R E Q U E S T    N E W    J O B    F R O M &
	!			Q U E M A N &
	&

20350	T$=CHR$(2%) \ GOTO 20200 &
		! SET UP A NEW JOB PACKET OF THE FORM : &
		!	(2) &
		! GO SEND IT. &

20360	! &
	! &
	! &
	!	R E Q U E S T    N E X T    P A C K E T    F R O M &
	!			Q U E M A N &
	&

20370	T$=CHR$(4%) \ GOTO 20200 &
		! SET UP A NEXT PACKET REQUEST OF THE FORM : &
		!	(4) &
		! GO SEND IT. &

20380	! &
	! &
	! &
	!	R E Q U E S T    F O R M S    C H A N G E    F R O M &
	!			Q U E M A N &

20390	T$=CHR12$+CVT%$(SWAP%(Z0%(Q9%,23%)))+CVT%$(SWAP%(Z0%(Q9%,24%))) &
	\ GOTO 20200 &
		! SET UP A 'FORMS REQUEST' OF THE FORM : &
		!	(12)(FORM NAME IN RAD50); &
		! GO SEND IT TO QUEMAN. &
	&

20400	! &
	! &
	! &
	!	R E Q U E S T    R E S T A R T    F R O M &
	!			Q U E M A N &
	&

20410	T$=CHR$(9%) \ GOTO 20200 &
		! SET UP A RESTART REQUEST OF THE FORM : &
		!	(9) &
		! GO SEND IT. &
	&

20420	! &
	! &
	! &
	!	R E Q U E S T    R E Q U E    F R O M &
	!		Q U E M A N &
	&

20430	T$=CHR10$+CHR10$ &
	\ T$=T$+CVT%$(Z0%(J9%,Z%)) FOR Z%=55% TO 59% &
	\ GOTO 20200 &
		! SET UP A REQUE REQUEST OF THE FORM : &
		!	(10)(NUMBER OF BYTES FOLLOWING) &
		!	 (WORD 1)(WORD 2)(WORD 3)(WORD 4) &
		!	  (WORD 5) &
		! GO SEND IT. &
	&

20440	! &
	! &
	! &
	!	T E L L    Q U E M A N    A B O U T    E N D &
	!		O F    J O B &
	&

20450	T$=CHR$(3%) \ R0%,Z0%(J9%,31%)=R0% AND -9% &
	\ GOTO 20200 &
		! SET UP AN END JOB PACKET OF THE FORM : &
		!	(3) &
		! RESET THE 'ENDJOB NEEDED' FLAG ON THE JOB; &
		! GO SEND THE END JOB. &
	&

20460	! &
	! &
	! &
	!	R E Q U E S T    D E F E R R A L    O F    J O B &
	!		B Y    Q U E M A N &
	&

20470	T$=CHR$(11%) \ GOTO 20200 &
		! SET UP A DEFER PACKET OF THE FORM : &
		!	(11) &
		! GO SEND IT. &
	&

20900	! &
	! &
	! &
	!	R E Q U E S T    A    N E W    J O B &

20910	F2% = F2% AND -3% &
	\ F2%=F2% OR 2% IF (R% AND 8%+32%+64%+128%) &
	\ IF Z0%(0%,2%) THEN &
		R%=R% OR 128% &
	\	F2%=F2% OR 2% &
	\	GOTO 20940 &
		! IF THE JOB LIST IS NOT EMPTY, THEN &
		!	SET THE 'JOB READY' STATUS FLAG, TO GUARANTEE &
		!	 THAT THE POLLING ROUTINE WILL RETURN &
		!	 IMMEDIATELY UPON COMPLETION OF POLL; &
		!	SET THE 'NON-JOB ACTION' FLAG; &
		!	GO CALL THE POLLING ROUTINE. &

20920	R%=R% AND -129% &
	\ IF (R% AND 8194%)=8194% THEN &
		IF (F2% AND 8%) THEN &
			F2%=F2% AND -9% &
		ELSE	F1%=F1% OR 8% &
	\		WHILE (R% AND 4%)=0% &
	\			T$="'STEP' NEEDED" &
	\			GOSUB 23500 &
	\			R%=R% OR 4% &
	\		NEXT &
		! RESET THE 'JOB READY' STATUS; &
		! IF 'STEP MODE' IS ON IN THE PROGRAM'S STATUS WORD, AND &
		!  THE JOB IS ONLINE TO QUEMAN, THEN &
		!	IF THE 'STEP' EVENT STATUS IS ON, THEN &
		!		RESET THE 'STEP' EVENT STATUS (SINCE THE &
		!		 NEXT OPERATION IS TO ASK QUEMAN FOR A &
		!		 NEW JOB); &
		!	ELSE	SET THE 'STEP' EVENT FLAG; &
		!		IF THE 'STEP NEEDED' MESSAGE HAS NOT &
		!		 YET BEEN ISSUED, THEN ISSUE IT; &
		!		GO TO THE POLLING ROUTINE. &

20930	S0%=0% \ F1%=0% \ GOSUB 21000 IF M%(2%) &
	\ IF (R% AND 448%)=0% &
	  THEN	IF (R% AND 8192%) AND Z0%(0%,16%)=0% THEN &
		GOSUB 20340 &
	\	Z%=FNPUSH%(P0%) &
	\	P0%=FNA% &
	\	R0%,Z0%(P0%,31%)=32% OR NOT32767% &
	\	Z0%(0%,16%)=P0% &
	\	GOSUB 20360 &
	\	P0%=FNPOP% &
		! IF THE PROGRAM IS ONLINE TO 'QUEMAN' (8192 BIT), AND &
		!  NO NEW JOB IS BEING SET UP (IE, THE QUEMAN JOB &
		!  POINTER, WORD 16 OF THE FILE HEADER RECORD, IS 0), &
		!  THEN &
		!	SEND QUEMAN A NEW JOB REQUEST (LINE 20500); &
		!	SET UP A JOB RECORD FOR QUEMAN'S JOB, SETTING &
		!	 THE 'NEW JOB EXPECTED' FLAG; &
		!	REQUEST A NEXT PACKET. &

20940	F1%=F1% OR 2% &
	\ GOSUB 21000 &
	\ Z0%(0%,27%)=Z0%(0%,2%) &
	\ R%=R% AND -129% UNLESS Z0%(0%,27%) &
		! SET THE 'JOB READY' EVENT FLAG; &
		! GO TO THE POLL ROUTINE; &
		! LOAD THE FIRST ENTRY OF THE READY JOB LIST INTO THE &
		!  CURRENT JOB POINTER; &
		! RESET THE 'JOB READY' STATUS IF THE CURRENT JOB &
		!  POINTER IS 0. &

20950	RETURN &
		! AND EXIT. &
	&

21000	! &
	! &
	! &
	!	P O L L I N G    R O U T I N E S &

21010	S1%,S2%,S3%=0% &
		! INIT TIMERS TO 0 TO PREVENT A SLEEP ON THE FIRST &
		! TIME THROUGH THE ROUTINE. &
		! TIMERS ARE : &
		!	S1%	- RECEIVE WITH SLEEP TIMER &
		!	S2%	- GET FROM KB: WITH SLEEP TIMER &
		!	S3%	- PLAIN OLD SLEEP TIMER, IN CASE THE &
		!			JOB IS NEITHER ATTACHED NOR A &
		!			RECEIVER. &
	&
	&

21100	! &
	! &
	! &
	!	G E T    A N D    P R O C E S S    C O M M A N D &

21110	TOD.=TIME(0%) &
		! STORE THE ENTRY TIME OF DAY.
21120	R%=R% AND 32767% &
		! CLEAR THE 'PROMPT REQUESTED FLAG', IN CASE IT GOT SET. &

21160	IF (R% AND 2048%) THEN &
		IF (PEEK(J0%) AND -256%) THEN &
			ON ERROR GOTO 19000 &
	\		M$=SYS(CHR6$+CHR$(18%)+CHR$(1%)) &
	\		N1%=ASCII(MID(M$,5%,1%))/2% &
	\		N2%=CVT$%(MID(M$,7%,2%)) &
	\		N%=ASCII(MID(M$,9%,1%)) &
	\		M$=MID(M$,10%, &
			   ((N%-1%) AND N%<21%) OR (19% AND N%>20%)) &
	\		N%=(N%<21%) &
	\		GOTO 21200 &
		! IF THIS JOB IS A RECEIVER, THEN &
		!	IF A MSG IS QUEUED, THEN &
		!		GET IT; &
		!		EXTRACT FROM IT THE JOB # (N1%), PPN &
		!		  PPN (N2%); &
		!		SET UP THE 'COMPLETED' FLAG - -1% IF THE &
		!		 MESSAGE IS COMPLETE, 0 OTHERWISE; &
		!		GO STORE IT AWAY. &

21170	IF S1%=0% THEN &
		GOTO 21400 &
	ELSE	SLEEP S1% &
	\	S1%=0% &
	\	GOTO 21160 &
		! IF NO WAIT TIMER IS SET FOR A SLEEP (S1%), THEN &
		!	GO EXIT FROM THE 'GET A MESSAGE' LOOP; &
		! ELSE	SLEEP THE ALLOTTED TIME; &
		!	RESET THE TIMER, SO NO SLEEP IS DONE NEXT TIME; &
		!	GO SEE IF ANYTHING ARRIVED WHILE YOU WERE OUT. &
	&
	&

21200	! &
	! &
	! &
	!	S T O R E    A    M E S S A G E &
	&

21210	GOTO 21400 IF N1%=0% OR (LEN(M$)=0% AND F1%>=0%) &
	\ M%=M%(0%) &
	\ M%=Z0%(M%,1%) WHILE M% AND Z0%(M%,6%)<>N1% &
	\ IF M%=0% THEN &
		M%=FNA% &
	\	Z0%(M%(1%),1%)=M% IF M%(1%) &
	\	Z0%(M%,1%)=M%(1%) &
	\	M%(0%)=M% UNLESS M%(0%) &
	\	M%(1%)=M% &
	\	Z0%(M%,6%)=N1% &
	\	Z0%(M%,7%)=N2% &
	\	N7%,Z0%(M%,12%)=ASCII(M$) &
	\	IF N7%=31% &
		OR (-1% < N7% AND N7% < 6%) &
		THEN &
			M$=RIGHT(M$,2%) &
		ELSE	N7%,Z0%(M%,12%)=6% &
		! SKIP THIS ROUTINE IF NO MESSAGE; &
		! FIND THE PLACE TO INSERT IN INCOMPLETE LIST; &
		! IF NO PARTIAL MESSAGE IS FOUND FOR THIS JOB, THEN &
		!	SET UP AND LINK IN A NEW MESSAGE RECORD; &
		!	SET UP THE DISPATCH CODE : &
		!	IF THE FIRST CHR IS ALREADY A DISPATCH CODE, &
		!	 THEN &
		!		REMOVE IT FROM THE RECORD; &
		!	ELSE	SET UP A DISPATCH OF 6, THE DECODE &
		!		 DISPATCH. &

21220	Z%=FNPUSH%(Z0%(M%,1%)) &
	\ Z0%(M%,1%)=Z0%(M%,2%) &
	\ Z%=FNPUSH%(M%) &
	\ M0%=Z0%(M%,13%) &
	\ M1%=28% &
	\ WHILE M0%>128%-M1% &
	\	M0%=M0%-(128%-M1%) &
	\	M1%=12% &
	\	M%=Z0%(M%,1%) &
	\ NEXT &
	\ M1%=M0%+M1% &
	\ M2%=LEN(M$) &
	\ M3%=0% &

21230	Z$=Z0$(M%) &
	\ Z0$(M%)=Z$+STRING$(M1%-LEN(Z$),0%)+MID(M$,M3%+1%,128%-M1%) &
	\ M3%=M3%+128%-M1% &
	\ IF M3%<M2% THEN &
		M%,Z0%(M%,1%)=FNA% &
	\	M1%=12% &
	\	GOTO 21230 &

21240	M%=FNPOP% &
	\ Z0%(M%,13%)=Z0%(M%,13%)+LEN(M$) &
	\ Z0%(M%,2%)=Z0%(M%,1%) &
	\ Z0%(M%,1%)=FNPOP% &
	\ IF N% THEN &
		M9%=0% \ M8%=2% \ GOSUB 21300 &

21250	GOTO 21400 &
	&

21300	! &
	! &
	! &
	!	S H I F T    A    M E S S A G E    B E T W E E N &
	!			L I S T S &
	&

21310	M0%=Z0%(M%,0%) &
	\ M1%=Z0%(M%,1%) &
	\ Z0%(M%,1%)=0% &
	\ Z0%(M0%,1%)=M1% IF M0% &
	\ Z0%(M1%,0%)=M0% IF M1% &
	\ M%(M9%)=M1% UNLESS M0% &
	\ M%(M9%+1%)=M0% UNLESS M1% &
	&
	\ WHILE M8% &
	\	M0%=M%(M8%+1%) &
	\	Z0%(M%,0%)=M0% &
	\	Z0%(M%,1%)=0% &
	\	Z0%(M0%,1%)=M% IF M0% &
	\	M%(M8%+1%)=M% &
	\	M%(M8%)=M% UNLESS M0% &
	\	M8%=0% &
	\ NEXT &
	\ RETURN &
	&
	&

21350	! &
	! &
	! &
	!	I L L E G A L    C O M M A N D &
	&

21360	T$="%ILLEGAL COMMAND - "+C$ &
	\ GOSUB 23500 &
	\ RETURN &
		! IF THE COMMAND ENTERED WAS A RECOGNIZABLE COMMAND, BUT &
		!  WAS NOT LEGAL FOR THIS PROGRAM, THEN &
		!	SET UP AND ISSUE A MESSAGE TO THAT EFFECT; &
		!	EXIT. &
	&
	&

21400	! &
	! &
	! &
	!	P R O C E S S    R E Q U E S T &

21410	WHILE M%(2%) &
	\	M%=M%(2%) &
	\	P%=Z0%(M%,11%) &
	\	N7%=Z0%(M%,12%) &
	\	C$=FNUNPACK$(M%,26%) &
	\	E%=0% &
	\	ON N7% GOSUB &
			24010,24200,24300,24100,21900,21600,21890,21750, &
			22420,22430,21350,21950,22000,22100,21350,21700, &
			21720,21730,21740,21350,21350,21350,21350,21350, &
			21350,21770,21350,21350,21350,21350,22440 &
				IF (0% < N7% AND N7% < 32%) &
	\	WHILE E% AND M%<>0% &
	\		T$="%"+T$+C9$+"'"+C$+"' IGNORED" &
	\		GOSUB 23500 &
	\		E%=0% &
	\	NEXT &
	\	WHILE M% &
	\		M9%=2% \ M8%=0% \ GOSUB 21300 &
	\		M%=FNA0%(M%) &
	\	NEXT &
	\ NEXT &
		! WHILE THERE ARE ANY COMPLETE MESSAGES : &
		!	SET UP THE MESSAGE NUMBER IN M%; &
		!	DISPATCH TO THE PROPER ROUTINE FOR THE MESSAGE'S &
		!	 TOKEN : &
		!	1   24010	NEWJOB FROM QUEMAN &
		!	2   24200	ENDJOB FROM QUEMAN &
		!	3   24300	KILLJOB FROM QUEMAN &
		!	4   24100	NEXT (FILE) PACKET FROM QUEMAN &
		!	5   21900	ONLINE REQUEST FROM QUEMAN &
		!	6   21600	COMMAND DECODE &
		!	7   21890	ONLINE FROM KB:/OPSER &
		!	8   21750	OFFLINE FROM OPSER &
		!	9   22420	PAUSE &
		!	10  22430	CONTINUE &
		!	11  21350	TRANSFER THE LOG FILE &
		!	12  21950	INSERT A NOTICE TO THE OUTPUT &
		!			 LOG &
		!	13  22000	RETYPE LAST MESSAGE &
		!	14  22100	RETURN A STATUS REPORT &
		!	15  21350	GIVE A LIST OF LEGAL COMMANDS &
		!	16  21700	ENTER STEP MODE OR STEP JOB &
		!	17  21720	EXIT STEP MODE &
		!	18  21730	END OPERATIONS (IE, KILL &
		!			 YOURSELF) &
		!	19  21740	ABORT THE CURRENT PROCESS &
		!	20  22300	CHANGE FORMS &
		!	21  23600	RESTART THE CURRENT PROCESS &
		!	22  23600	REQUE THE CURRENT PROCESS &
		!	23  21350	SEND THE SPECIFIED FILE(S) NEXT &
		!	24  21350	INTERRUPT THE CURRENT PROCESS IN &
		!			ORDER TO SEND THE SPECIFIED &
		!			FILE(S) &
		!	25		CHANGE THE OUTPUT FILE(S) FOR &
		!			PRINT OR PUNCH OUTPUT &
		!	26  21770	RESPONSE TO BE RETURNED TO &
		!			 CALLER &
		!	27  21350	TAKE THE JOB OFF LINE FROM OPSER &
		!	28  21350	PUT THE JOB ONLINE TO QUEMAN &
		!	29  21350	TAKE THE JOB OFFLINE FROM QUEMAN &
		!	30  21350	DETACH THE JOB &
		!	31  22440	PROCESS 'FORMS CHANGE ACK' &
		!			 FROM QUEMAN &
		!	IF ANY ERROR IS SET UPON RETURN, THEN &
		!		SET UP AND PRINT AN ERROR MESSAGE; &
		!	IF, UPON RETURN FROM THE PROCESS, THE MESSAGE &
		!	 POINTER IS NON-ZERO, THEN &
		!		REMOVE THE MESSAGE FROM THE COMPLETE &
		!		 LIST AND REPLACE IT IN THE FREE-LIST; &
		! LOOP UNTIL NO MORE COMPLETED MESSAGES EXIST. &

21440	IF S3% THEN &
		SLEEP S3% &
	\	S3%=0% &
	\	GOTO 21120 &
		! IF THE 'SLEEP TIMER' (S3%) IS NON-ZERO, THEN &
		!	GO INTO A SLEEP FOR MORE DATA; &
		!	RESET SLEEP TIMER SO NO SLEEP IS DONE NEXT TIME; &
		!	GO SEE IF ANYTHING ARRIVED WHILE YOU WERE OUT. &
	&
	&

21500	! &
	! &
	! &
	!	D E C I D E    O N    N E X T    S T E P &

21510	TOD.=TIME(0%)-TOD. &
	\ TOD.=TOD.+86400. IF TOD.<0. &
	\ IF TOD.>65535. THEN &
		T0%=S0% &
	  ELSE	T0%=TOD.-32768. &
	\	T0%=T0% EQV 32767% &
		! STORE THE ELAPSED EXECUTION TIME; &
		! ADJUST FOR DATE WRAP-AROUND, IF NECESSARY; &
		! IF THE ELAPSED TIME IS GREATER THAN WHAT CAN BE HELD &
		! IN AN INTEGER, THEN &
		!	SET THE ELAPSED TIME TO THE REQUESTED TIME; &
		! ELSE	PUT IT IN AN INTEGER, ADJUSTING FOR THE SIGN &
		!	BIT. &
	&

21520	F2%=F2% AND -2% &
	\ T0%=S0%-T0% &
	\ F2%=F2% OR 1% IF T0%=0% OR (T0%<0% AND S0%>-1%) &
	\ T0%=0% IF (F2% AND 1%) &
	\ S0%=T0% &
		! RESET THE 'SLEEP TIME EXPIRED' FLAG; &
		! CALCULATE THE NEW 'SLEEP TIME' VALUE; &
		! SET THE 'SLEEP TIME EXPIRED' FLAG IF EITHER &
		!  THE NEW SLEEP TIME IS 0 &
		!	OR &
		!  THE OLD SLEEP TIME WAS POSITIVE AND THE &
		!  NEW SLEEP TIME IS NEGATIVE (IE, IT WENT THROUGH &
		!  A TRANSITION THROUGH 0); &
		! SET THE NEW SLEEP TIME TO 0 IF THE SLEEP TIME IS &
		!  EXPIRED. &

21530	S1%,S2%,S3%=0% &
	\ GOTO 21120 IF R%<0% &
	\ IF F1%=0% OR (F1% AND F2%) THEN &
		R%=R% AND -1025% &
	  ELSE	S0%=-1% IF S0%=0% &
	\	S1%=S0% IF (R% AND 2048%) &
	\	S2%=S0% IF (R% AND 16384%+2048%)=16384% &
	\	S3%=S0% IF (R% AND 16384%+2048%)=0% &
	\	GOTO 21100 &
		! GO MAKE SURE A NEW PROMPT IS PRINTED BEFORE CHECKING &
		!  FOR EXIT; &
		! IF THE EVENT REQUEST FLAG IS NON-ZERO AND NONE OF THE &
		!  EVENTS MATCH, THEN &
		!	ZERO OUT THE TIMERS, TO START WITH; &
		!	SET THE REQUESTED TIME TO INFINITE, IF IT IS NOT &
		!	 SET (IF THE EXPIRATION OF THE TIMER WAS A &
		!	 DESIRED EVENT, THEN THE EVENT FLAG SHOULD HAVE &
		!	 BEEN SET, AND THIS LINE WOULD NOT HAVE BEEN &
		!	 REACHED); &
		!	SET UP THE PROPER TIMER : &
		!		RECEIVE TIMER (S1%) IF THE PROGRAM IS &
		!		 A RECEIVER; &
		!		KEYBOARD TIMER (S2%) IF THE PROGRAM IS &
		!		 ATTACHED AND NOT A RECEIVER; &
		!		SLEEP TIMER (S3%) IF THE PROGRAM IS &
		!		 NEITHER A RECEIVER NOR ATTACHED; &
		!	GO BACK AND LOOK FOR ANOTHER MESSAGE. &

21540	ON ERROR GOTO 19000 &
	&
	\ R%=R% AND NOT 1536% &
	&
	\ RETURN &
	&
		! RESET ERROR TRAP. &
	&
		! AND EXIT. &
	&
	&

21600	! &
	! &
	! &
	!	D E C O D E    R O U T I N E &
	&

21610	Z%=0% &
	\ IF C$<>NULSTG$ OR (F1%<0% AND (F1% AND F2%)>=0%) THEN &
		RESTORE \ Z$=NULSTG$ \ READ Z$ UNTIL Z$="*STARTCOM" &
	\	P%=0% &
	\	WHILE P%=0% AND T$<>"*ENDCOM" &
	\		READ T$,N7% &
	\		Z%=FNR%(T$,N7%) &
	\		P%=0% UNLESS Z% &
	\		READ Z% &
	\	NEXT &
	\	IF P%=0% THEN &
			IF F1%<0% AND (F1% AND F2%)>=0% THEN &
				Z%=26% &
			ELSE	T$="UNRECOGNIZED COMMAND" &
	\			E%=-1% &
	\			GOTO 21630 &
		! SET UP THE COMMAND IN THE USUAL STRING; &
		! IF THE STRING IS NON-NULL OR THE CALLER IS WAITING &
		!  FOR A RESPONSE, THEN &
		!	GET TO THE BEGINNING OF THE COMMAND TABLE; &
		!	WHILE A MATCH IS NOT FOUND AND THE TABLE IS NOT &
		!	 EMPTY : &
		!		READ THE NEXT ENTRY; &
		!		SEE IF THIS ONE MATCHES; &
		!		READ THE ROUTINE NUMBER; &
		!	LOOP ON NO MATCH; &
		!	IF NO MATCH WAS FOUND, THEN &
		!		IF A RESPONSE IS EXPECTED, THEN &
		!			ASSUME THAT THIS IS IT, AND SET &
		!			 UP TO RETURN IT; &
		!		ELSE	SET UP AN ERROR MESSAGE AND SET &
		!			 ERROR FLAG; &
		!			EXIT THE ROUTINE WITH THE &
		!			 MESSAGE POINTER STILL POINTING &
		!			 TO THIS ONE, SO IT WILL BE &
		!			 REMOVED. &

21620	Z0%(M%,12%)=Z% &
	\ Z0%(M%,11%)=P% &
	\ M%=0% &
		! IF THIS LINE IS EXECUTED, THE COMMAND WAS FOUND, SO &
		!	READ THE NEW DISPATCH TOKEN VALUE; &
		!	RESET THE MESSAGE POINTER SO THAT THE MESSAGE IS &
		!	 LEFT IN THE MESSAGE COMPLETED LIST. &

21630	RETURN &
		! AND EXIT. &
	&
	&
	&

21650	DATA	"*STARTCOM", &
		ONLINE,		3,	7, &
		OFFLINE,	3,	8, &
		PAUSE,		3,	9, &
		CONTINUE,	3,	10, &
		NOTICE,		3,	12, &
		LAST,		3,	13, &
		STATUS,		3,	14, &
		STEP,		3,	16, &
		NOSTEP,		5,	17, &
		END,		3,	18, &
		ABORT,		3,	19 &
	&

21660	DATA "*ENDCOM",0,0,
21661		! DEFINE THE COMMANDS AND THEIR ROUTINES : &
		!	THE FORMAT IS : &
		!	  <COMMAND NAME>,<MATCH LENGTH>,<ROUTINE NUMBER> &

21700	IF (R% AND 2%)=0% THEN &
		R%=R% OR 2% &
	ELSE	F2%=F2% OR 8% &
		! 'STEP' - &
		! EITHER : &
		!	ENTER STEP MODE, IF NOT ALREADY IN IT, &
		! OR &
		!	SET 'STEP JOB RECEIVED' STATUS FLAG. &

21710	GOTO 24970 &
		! EXIT. &

21720	T$="NOT IN 'STEP' MODE" &
	\ E%=(R% AND 2%)=0% &
	\ R%=R% AND NOT (2%+4%) IF E%=0% &
	\ F2%=F2% OR 8% IF E%=0% &
	\ GOTO 24970 &
		! 'NOSTEP' - &
		! RESET THE TWO STEP MODE FLAGS; &
		! SET 'STEP JOB RECEIVED', IN CASE THE JOB IS WAITING &
		!  FOR A 'STEP' COMMAND; &
		! EXIT. &

21730	F2%=F2% OR 2% &
	\ R%=R% OR 64% &
	\ GOTO 24970 &
		! 'END' - &
		! SET THE 'END REQUESTED' FLAG ON THE STATUS WORD; &
		! EXIT. &

21740	IF (R% AND 1%)=0% THEN &
		GOTO 24960 &
	ELSE	GOTO 23600 &
		! 'ABORT' - &
		! IF NO JOB IS IN PROCESS, THEN &
		!	GO ISSUE ERROR MESSAGE TO THAT EFFECT; &
		! ELSE	SET THE 'ABORT REQUESTED' FLAG ON THE JOB'S &
		!	 PROCESSES REQUESTED WORD; &
		!	SET 'SOME JOB MODIFICATION REQUESTED' STATUS; &
		!	EXIT. &

21750	GOSUB 21730 &
	\ GOSUB 21740 IF (R% AND 1%) &
	\ GOTO 24970 &
		! 'OFFLINE' - &
		! CALL THE 'END' ROUTINE TO SET UP AN 'END'; &
		! CALL THE 'ABORT' ROUTINE IF A JOB IS ACTIVE; &
		! EXIT. &

21770	F2%=F2% OR NOT32767% &
	\ GOSUB 23140 &
	\ R$=C$ &
	\ GOTO 24970 &
		! 'RESPONSE TO REQUEST' - &
		! SET 'RESPONSE RECEIVED' STATUS; &
		! HOLD THE RESPONSE; &
		! EXIT. &

21890	R%=R% AND -4097% &
	\ GOSUB 23100 &
	\ GOTO 24970 &
		! 'ONLINE' (FROM OPSER OR KB:) - &
		! RESET THE 'ONLINE TO OPSER' FLAG, SO THE ONLINE &
		!  ROUTINE WILL ACTUALLY SET UP AND SEND THE MESSAGE; &
		! CALL THE ONLINE ROUTINE; &
		! EXIT. &

21900	R%=R% AND -8193% &
	\ GOSUB 20300 &
	\ IF Z0%(0%,16%)=0% THEN &
			GOTO 24970 &
	  ELSE Z0%(0%,16%)=FNA0%(Z0%(0%,16%)) &
		\ F2%=F2% OR 2% &
		\ GOTO 24970 &
		! 'ONLINE' (FROM QUEMAN" &
		! RESET THE 'ONLINE TO QUENAM' FLAG, SO THE ROUTINE WILL &
		!  ACTUALLY DO THE SEND; &
		! CALL THE ROUTINE; &
		! EXIT. &
	&

21950	! NOTICE FROM OPERATOR. &

21960	GOTO 24960 UNLESS J9% &
	\ M9%=2% \ M8%=0% \ GOSUB 21300 &
	\ Z%=Z0%(J9%,5%) &
	\ IF Z%=0% THEN &
		Z0%(J9%,5%)=M% &
	  ELSE Z%=Z0%(Z%,1%) WHILE Z0%(Z%,1%) &
	\ 	Z0%(Z%,1%)=M% &
		! ISSUE ERROR IF NO JOB IS ACTIVE; &
		! REMOVE THE NOTICE FROM THE 'COMPLETE MESSAGE LIST'; &
		! FINE THE END OF THE CURRENT 'NOTICE' LIST FOR THIS &
		!  JOB; &
		! PUT THE TEXT RECORD(S) INTO THE LIST/ &

21970	M%=0% \ GOTO 24970 &
		! EXIT. &
	&

22000	T$="Last message was :"+C9$+R1$ &
	\ R2$=R1$ &
	\ R%=R% AND -1025% &
	\ GOSUB 23500 &
	\ R1$=R2$ &
	\ GOTO 24970 &
		! 'LAST' - &
		! SET UP TEXT STRING FOR ISSUANCE; &
		! GO ISSUE IT; &
		! TAKE OUT THE HEADING IF THE MESSAGE WAS SAVED; &
		! EXIT. &

22100	T$=S$+" STATUS"+C9$ &
	\ T$ = T$ + "CONTROLLING DEVICE = " &
		  + CVT$$(FNU$(Q9%,NULSTG$,   1%,0%),2%) + &
		": UNIT:"+FNU0$(Z0%(Q9%,11%))+" (" &
		  + FNU$(Q9%,NULSTG$,4096%,0%) +")" + C9$ &

22120	IF (R% AND 1%)=0% THEN &
		T$=T$+C9$+"WAITING FOR JOB" &
	ELSE	T$=T$+C9$+FNM0$(NULSTG$,J9%,P0%,0%,PGEFLG%)+C9$ &
		! SET UP THE PART OF THE MESSAGE TELLING WHAT KIND OF &
		!  JOB OPERATION IS GOING ON. &

22140	IF JOBMOD% THEN &
		T$=T$+C9$+"PREPARING TO 'REQUE' JOB"+C9$ IF &
			(Z0%(J9%,31%) AND 4%) &
	\	T$=T$+C9$+"PREPARING TO 'ABORT' JOB"+C9$ IF &
			(Z0%(J9%,31%) AND 1%) &
		! IF SOME JOB MODIFICATION IS OUTSTANDING, THEN &
		!	SET UP THE TEXT DESCRIBING IT. &

22190	GOSUB 23500 &
	\ GOTO 24970 &
	&

22400	! &
	! &
	! &
	!	G E T    A    N U M B E R &
	! &
	! &
	! NOTE : THIS ROUTINE ASSUMES THAT A NUMBER MUST BE FOUND. &
	!	 THE ROUTINE DOES NOT KNOW ABOUT SIGNED NUMBERS. &

22410	E%=(FNR%(":",1%)=0%) &
	\ NUMBER%=FNN% UNLESS E% &
	\ E%=E% OR (F%=0%) &
	\ RETURN &
		! FIND A COLON, NUMBER, AND RETURN. &
	&

22420	T$="ALREADY IN 'PAUSE'" &
	\ E%=(F1% AND 16384%) &
	\ GOTO 24970 IF E% &
	\ F1%=FNPUSH%(F1%) &
	\ S0%=FNPUSH%(S0%) &
	\	F1%=2%+16%+16384%+(NOT32767% AND F1%) &
	\	Z0%(M%,12%)=0% &
	\	GOSUB 21000 &
	\ S0%=FNPOP% &
	\	F1%=FNPOP% &
	\	F2%=F2% AND -16385% &
	\	GOTO 24970 &
		! 'PAUSE' - &
		! SET UP AN ERROR IF ALREADY IN PAUSE STATE; &
		! ELSE	PUSH THE CURRENT VALUE OF THE 'EVENTS REQUESTED' &
		!	 FLAG; &
		!	SET UP THE FOLLOWING EVENTS TO RETURN FROM THE &
		!	 PAUSE : &
		!		END &
		!		FORM CHANGE &
		!		JOB INTERRUPT &
		!		OFFLINE &
		!		CONTINUE &
		!	CALL THE POLLING ROUTINE TO WAIT FOR ONE OF &
		!	 THEM; &
		!	POP THE OLD EVENT FLAG; &
		!	RESET 'CONTINUE RECEIVED' STATUS; &
		! EXIT. &

22430	T$="NOT IN 'PAUSE'" &
	\ E%=(F1% AND 16384%)=0% &
	\ F2%=F2% OR 16384% IF E%=0% &
	\ GOTO 24970 &
		! 'CONTINUE' - &
		! SET UP ERROR IF NOT IN PAUSE STATE; &
		! ELSE	SET 'CONTINUE RECEIVED' STATUS FLAG; &
		! EXIT. &
	&

22440	R% = R% AND -17% &
	\ GOTO 24970 &
		! CLEAR THE 'FORMS CHANGE ACK NEEDED' FLAG. &
	&

23000	! &
	! &
	! &
	!	O P S E R - R E L A T E D    S U B R O U T I N E S &
	&

23050	! &
	! &
	! &
	!	E N T E R    R E C E I V E R &

23080	J0%=SWAP%(CVT$%(MID(SYS(UU1$),29%,2%))) &
	\ IF J0%=0% THEN &
		GOTO 23900 &
	  ELSE	J0%=J0%+14% &
	\	R%=R% OR 2048% &
	\	GOTO 23900 &
		! TAKE THE ADDRESS OF THE MESSAGE RECEIVER ENTRY OUT OF &
		!  JDB2; &
		! IF THE ADDRESS IS 0, THEN &
		!	WE FAILED TO ENTER OURSELVES, SO GO EXIT; &
		! ELSE	SET J0% TO POINT TO THE PLACE IN THE MESSAGE &
		!	 RECEIVER ENTRY WHEREIN IS STORED THE COUNT OF &
		!	 MESSAGES QUEUED FOR THIS JOB (THE COUNT IS IN &
		!	 THE HIGH BYTE OF THIS WORD); &
		!	SET THE 'ENTERED AS RECEIVER' FLAG; &
		!	EXIT. &
	&
	&

23100	! &
	! &
	! &
	!	S E N D    O N L I N E    T O    O P S E R &
	&

23110	T0$=CHR6.18.M1.0$+ &
		MID(SYS(CHR6.M10$+"OPSER"),7%,4%) &
	\ IF (R% AND 4096%) THEN &
		GOTO 23900 &
	  ELSE	Z%=FNPUSH%(R%) &
	\	R%=R% AND -16385% &
	\	T$=CHR192$+"ONLINE 1" &
	\	GOSUB 23500 &
	\	R%=FNPOP% OR R% &
	\	GOTO 23900 &
		! FIRST, SET UP THE STRING TO BE USED IN THE SEND TO &
		!  OPSER, REGARDLESS OF WHETHER OR NOT THE JOB HAS &
		!  ALREADY DONE AN ONLINE TO OPSER OR NOT - THE &
		!  ROUTINE IS CALLED BY THE SET-UP ROUTINES TO ENSURE &
		!  THAT THE COMMUNICATION STRING IS BUILT PROPERLY; &
		! IF THE JOB HAS ALREADY DONE AN ONLINE, THEN &
		!	GOTO THE EXIT; &
		! ELSE	PUSH THE CURRENT PROGRAM STATUS AND RESET THE &
		!	 ATTACHED FLAG TO FORCE A SEND TO OPSER; &
		!	SET UP THE TEXT TO SEND AS 'ONLINE'; &
		!	GO ISSUE AN OPERATOR MESSAGE; &
		!	POP THE OLD VALUE OF THE STATUS WORD; &
		!	AND EXIT. &
		!	(IF THE SEND WAS SUCCESSFUL, THE SEND ROUTINE &
		!	HAS SET THE 'ONLINE' FLAG IN THE STATUS WORD.) &
	&

23140	! &
	! &
	! &
	!	D E L E T E    L A S T    M E S S A G E    T O &
	!			O P S E R &
	&

23150	IF (R% AND 4096%)=0% THEN &
		GOTO 23900 &
	ELSE	Z%=FNPUSH%(R%) &
	\	R%=R% AND -16385% &
	\	T$=CHR192$+"DELETE #"+J$ &
	\	GOSUB 23500 &
	\	R%=FNPOP% &
	\	GOTO 23900 &
		! IF THE 'ONLINE TO OPSER' FLAG IS NOT SET, THEN &
		!	GOTO EXIT; &
		! ELSE	PUSH THE CURRENT STATUS; &
		!	FORCE A SEND TO OPSER OF 'DELETE #<JOB NUMBER>'; &
		!	RESTORE THE STATUS. &
	&

23500	! &
	! &
	! &
	!	S E N D    T O    O P E R A T O R &

23510	R%=R% AND -513% &
	\ R8%=0% &
	\ Z%=FNPUSH%(P%) &
	\ P%=0% &
	\ IF (R% AND 1024%)=0% THEN &
		R1$=T$ &
	\	IF F1%<0% AND (F1% AND F2%)>=0% THEN &
			R%=R% OR 1024% OR 512% &
	\		T$=C8$+T$ &
		! RESET THE <CR><LF> INHIBIT FLAG; &
		! SET THE RETRY COUNTER FOR THE 'SEND' ROUTINE TO 0; &
		! PUSH THE CURRENT VALUE OF P%, SINCE THE ROUTINE WILL &
		!  USE P% AS A POSITION POINTER; &
		! SET THE VALUE OF P%; &
		! IF A MESSAGE IS NOT CURRENTLY STORED, THEN &
		!	STORE THIS ONE; &
		!	IF THIS MESSAGE IS A REQUEST (IE, THE 'USER &
		!	 RESPONSE' FLAG IN THE EVENT WORD IS SET AND &
		!	 IT IS NOT SET IN THE STATUS WORD), THEN &
		!		SET THE 'MESSAGE STORED' AND &
		!		 <CR><LF> INHIBIT FLAGS; &
		!		PUT A <BELL> ON THE FRONT OF THIS &
		!		 MESSAGE TO SIGNIFY AN ACTION REQUEST. &

23520	IF (R% AND 16384%) THEN &
		RESUME 23550 &
	  ELSE	ON ERROR GOTO 23530 &
	\	WHILE P%<LEN(T$) &
	\		Z%=LEN(T$)-P%+1% &
	\		Z%=255% IF Z%>20% &
	\		Z$=SYS(T0$+CHR$(Z%)+RIGHT(T$,P%+1%)) &
	\		R8%=0% &
	\		P%=P%+19% &
	\	NEXT &
	\	R%=R% OR 4096% &
	\	GOTO 23560 &
		! IF THE JOB IS FLAGGED AS ATTACHED, THEN &
		!	GO TO THE 'PRINT' ROUTINE; &
		! ELSE	SET ERROR TRAP; &
		!	SEND THE MESSAGE TO OPSER, 19 BYTES AT A TIME, &
		!	 USING THE STRING, T0$, SET UP BY THE 'ONLINE' &
		!	 ROUTINE; &
		!	SET THE 'ONLINE' FLAG. &

23530	IF ERR=32% THEN &
		R8%=R8%+1% &
	\	IF R8%<60% THEN &
			SLEEP 5% &
	\		RESUME 23520 &
		! IF THE ERROR MEANT 'NO ROOM FOR MESSAGE', THEN &
		!	INCREMENT THE RETRY COUNTER; &
		!	IF THE COUNTER IS STILL LESS THAN 60, THEN &
		!		SLEEP AWHILE; &
		!		TRY AGAIN TO SEND THE MESSAGE. &

23540	 RESUME 19000 &
		! IF THE ERROR WAS ANYTHING OTHER THAN 'NO ROOM', OR IF &
		!  THE RETRY COUNTER HAS EXPIRED, THEN &
		! 	FLAG IT AS FATAL AND CHAIN OUT TO SPOOL. &
		!	APPEND AN EXPLANATION TO THE MESSAGE; &
		!	SET AN ERROR; &
		!	GO PROCESS AS IF ATTACHED. &

23550	IF (R% AND 16384%) THEN &
		ON ERROR GOTO 0 &
	\	PRINT #0% IF CCPOS(0%) &
	\	PRINT #0%,T$; &
	\	PRINT #0% IF (R% AND 512%)=0% &
		! IF ATTACHED, THEN &
		!	RESET ERROR TRAP; &
		!	MAKE SURE THAT THE CARRIAGE IS AT THE LEFT &
		!	 MARGIN; &
		!	PRINT THE STRING WITHOUT <CR><LF>; &
		!	PRINT A <CR><LF> IF THE <CR><LF> INHIBIT FLAG IS &
		!	 NOT SET. &

23560	P%=FNPOP% &
	\ R%=R% OR NOT32767% &
	\ GOTO 23900 &
		! RESTORE THE ORIGINAL VALUE OF P%; &
		! SET THE 'PROMPT REQUIRED' FLAG; &
		! EXIT. &
	&

23600	! &
	! &
	! &
	!	S T O R E    A    M E S S A G E    I N T O    T H E &
	!		W O R K - F I L E    F O R    L A T E R &
	!			P R O C E S S I N G &

23610	M9%=2% \ M8%=4% \ GOSUB 21300 \ M%=0% &
		! SET UP THE CALL TO THE 'SHIFT A MESSAGE' ROUTINE : &
		!	TAKE FROM THE 'COMPLETED' LIST; &
		!	ENTER TO THE 'UNPROCESSED' LIST; &
		!	DO THE CALL, AND LET IT RETURN. &

23900	RETURN &
		! EXIT FROM ALL OPSER RELATED ROUTINES. &
	&
	&

24000	! &
	! &
	! &
	!	S O M E    P A C K E T    R E C E I V E D    F R O M &
	!			Q U E M A N &
	&

24010	! &
	! &
	! &
	!	N E W J O B    P A C K E T    R E C E I V E D &
	&

24020	GOTO 24970 IF (R% AND 16%) &
	\ GOSUB 24500 &
	\ GOTO 24400 UNLESS P0% &
	\ IF (R0% AND 32%)=0% THEN &
		T$="NEWJOB" \ T1$="FILE PACKET REQUESTED" \ GOTO 24400 &
		! USE THE COMMON ENTRY; &
		! PROCESS AN ERROR IF THE BUILD POINTER IS RETURNED AS &
		!  ZERO; &
		! IF NO NEWJOB IS EXPECTED, THEN &
		!	ISSUE AN ERROR. &

24030	Z%=FNCHNGE%(LEFT(CHR0$+C$,26%)) &
	\ Z%(15%)=SWAP%(Z%(15%)) &
	\ Z0%(P0%,8%)=Z%(7%) &
	\ Z0%(P0%,9%)=Z%(3%) \ Z0%(P0%,10%)=Z%(5%) &
	\ Z0%(P0%,11%)=Z%(2%) &
	\ Z0%(P0%,14%)=4225% &
	\ Z0%(P0%,17%)=2% &
	\ Z0%(P0%,25%)=Z%(15%) AND 127% &
	\ Z0%(P0%,19%)=SWAP%(Z%(19%)) \ Z0%(P0%,20%)=SWAP%(Z%(13%)) &
	\ Z0%(P0%,21%)=SWAP%(Z%(9%)) \ Z0%(P0%,22%)=SWAP%(Z%(11%)) &
	\ Z0%(P0%,23%)=Z%(21%) \ Z0%(P0%,24%)=Z%(23%) &
	\ Z0%(P0%,28%)=(Z%(17%) AND 255%) &
	\ Z0%(P0%,30%)=SWAP%(Z%(17%)) AND 255% &
	\ Z0%(P0%,35%)=SWAP%(Z%(25%)) &
	&
	\ R1%=R1% OR 1% IF (Z%(17%) AND -256%) &
	\ R1%=R1% OR 4% IF (Z%(13%) OR Z%(19%)) &
	\ R1%=R1% OR 8% IF 0% &
	\ R1%=R1% OR 16% IF (Z%(21%) OR Z%(23%)) &
	\ R1%=R1% OR 32% IF (Z%(15%) AND 127%) &
	\ R1%=R1% OR 64% IF 0% &
	\ R1%=R1% OR (Z%(15%) AND 32640%) IF Z%(15%) &
	\ R1%=R1% OR NOT32767% IF (Z%(17%) AND 255%) &
	\ Z0%(P0%,34%)=R1% &
	&
	\ R0%,Z0%(P0%,31%)=(R0% AND -33%) OR 64% &
	&
	\ Z%=ASCII(MID(C$,26%,1%))/2% &
	\ IF Z% THEN &
		R0%,Z0%(P0%,31%)=R0% OR 16384% &
	\	Z0%(P0%,55%+Z0%)=CVT$%(MID(C$,Z0%*2%+27%,2%)) FOR &
		 Z0%=0% TO Z% &
		! CHANGE THE FIRST 26 CHARACTERS OF THE RECEIVED PACKET &
		!  INTO AN ARRAY; &
		! LOAD THE FOLLOWING : &
		!	FROM	TO	DATA &
		!	8,9	8	PPN OF JOB &
		!	3-6	9-10	JOB NAME &
		!	2	11	UNIT NUMBER &
		!	-	14	FW2 - FILE, PPN, DEVICE &
		!	-	17	SOURCE - 2 -> QUEMAN &
		!	15(127)	25	FORM LENGTH FROM /MODE:... &
		!	19,20,13,14 &
		!		19-20	AFTER DATE/TIME &
		!	9,10,11,12 &
		!		21-22	QUEUE DATE/TIME &
		!	21-24	23-24	FORM NAME &
		!	17(LOW)	28	TYPE VALUE &
		!	18(17 HIGH) &
		!		30	COPIES OF JOB REQUESTED &
		!	25	35	JOB SEQUENCE NUMBER &
	&
		! NEXT, SET UP THE SWITCH SPECIFICATION WORD FOR THE &
		!  JOB : &
		!	VALUE	MEANING &
		!	 1	COPIES &
		!	 2	**UNUSED** &
		!	 4	AFTER SPECIFIED &
		!	 8	HEADING COUNT &
		!	16	FORM NAME &
		!	32	FORM LENGTH &
		!	64	FORM WIDTH &
		!	128-16384 &
		!		MODE BITS FOR LP: (TWO EXTRA) &
		!	SGN	TYPE &
	&
	&
		! THEN RESET THE 'NEWJOB EXPECTED' FLAG AND SET THE &
		!  'FIRST FILE PACKET EXPECTED' FLAG. &
	&
		! CHANGE THE TRAILING INFORMATION INTO AN ARRAY; &
		! IF ANY DATA WAS THERE, THEN &
		!	THIS JOB WAS REQUEUED AND THE DATA IS RESTART &
		!	 INFO, SO STORE IT. &

24040	GOTO 24550 &
		! GO USE THE COMMON EXIT. &
	&

24100	! &
	! &
	! &
	!	F I L E    P A C K E T    R E C E I V E D &
	&

24110	GOTO 24970 IF (R% AND 16%) &
	\ GOSUB 24500 &
	\ GOTO 24400 UNLESS P0% &
	\ IF (R0% AND 192%)=0% THEN &
		T$="FILE PACKET" \ T1$="JOB PACKET EXPECTED" &
	\		GOTO 24400 &
		! SET UP THE COMMON ENTRANCE STUFF; &
		! PROCESS AN ERROR IF THE BUILD LIST POINTER IS RETURNED &
		!  AS ZERO; &
		! IF NO FILE PACKET IS EXPECTED, THEN &
		!	GO ISSUE A SYNCHRONIZATION ERROR. &

24120	P1%=FNPUSH%(P0%) &
	\ IF Z0%(P0%,2%)=0% THEN &
		P0%,Z0%(P0%,2%),Z0%(P0%,27%)=FNA% &
	  ELSE	P1%=Z0%(P0%,27%) &
	\	P0%,Z0%(P0%,27%),Z0%(P1%,1%)=FNA% &
		! PUSH THE ADDRESS OF THE JOB RECORD FOR LATER; &
		! IF THE JOB HAS NO FILE RECORDS AS YET, THEN &
		!	SET UP A FREE RECORD AS THE FIRST SUBLIST &
		!	 RECORD OF THE JOB HEADER; &
		! ELSE	USE THE 'CURRENT FILE RECORD' POINTER OUT OF THE &
		!	 JOB RECORD TO FIND THE LAST FILE RECORD; &
		!	APPEND ONTO THAT RECORD ANOTHER RECORD. &

24130	Z%=FNCHNGE%(LEFT(C$,30%)) &
	\ Z0%(P0%,6%)=Z%(1%) \ Z0%(P0%,7%)=Z%(3%) &
	\ Z0%(P0%,8%)=Z%(11%) &
	\ Z0%(P0%,9%)=Z%(5%) \ Z0%(P0%,10%)=Z%(7%) &
	\ Z0%(P0%,11%)=Z%(9%) &
	\ Z0%(P0%,13%)=1% &
	\ Z0%(P0%,14%)=4233% &
	\ Z0%(P0%,30%)=Z%(15%) AND 255% &
	\ Z0%(P0%,34%)=Z%(13%) AND 255% &
	\ Z0%(P0%,49%)=Z%(16%) &
	&
	\ P0%=FNPOP% &
	\ R0%,Z0%(P0%,31%)=(R0% AND -65%) OR 128% &
	\ Z0%(P0%,49%)=Z0%(P0%,49%) OR Z%(16%)<>0% &
	&
	\ GOTO 24550 &
		! CHANGE THE FIRST 30 BYTES TO AN ARRAY; &
		! LOAD : &
		!	FROM	TO	DATA &
		!	1-4	6,7	SOURCE DEVICE &
		!	11,12	8	SOURCE PPN &
		!	5-8	9,10	FILENAME &
		!	9-10	11	EXTENSION &
		!	-	13	DHI FOR SOURCE DEVICE &
		!	-	14	FW2 FOR DEVICE, FILENAME, EXT, &
		!			 PPN &
		!	15(LOW)	30	COPIES REQUESTED &
		!	13(LOW)	34	SWITCH SPECIFICATION WORD : &
		! &
		!				1	COPIES REQ. &
		!				2	RESTART REQ. &
		!				4	DELETE REQ. &
		!				8	BINARY REQ. &
		!				16	END REQ. &
		! &
		! POP THE ADDRESS OF THE JOB RECORD; &
		! RESET THE 'FIRST FILE EXPECTED' FLAG AND SET THE &
		!  'NON-FIRST FILE EXPECTED' FLAG; &
		! GO USE THE COMMON EXIT. &
	&

24200	! &
	! &
	! &
	!	E N D J O B    P A C K E T    R E C E I V E D &
	&

24210	GOTO 24970 IF (R% AND 16%) &
	\ GOSUB 24500 &
	\ GOTO 24400 UNLESS P0% &
	\ IF (R0% AND 128%)=0% THEN &
		T$="ENDJOB PACKET" \ T1$="FIRST FILE PACKET EXPECTED" IF &
			(R0% AND 64%) &
	\		T1$="NEW JOB PACKET EXPECTED" UNLESS &
				(R0% AND 64%) &
	\		GOTO 24400 &
		! USE THE COMMON SET UP; &
		! PROCESS AN ERROR IF THE BUILD LIST POINTER IS RETURNED &
		!  AS ZERO; &
		! IF THE 'FILE EXPECTED' FLAG IS NOT ON, THEN &
		!	GO ISSUE APPROPRIATE SYNCHRONIZATION ERROR. &

24220	Z0%(0%,16%)=0% &
	\ IF Z0%(0%,2%)=0% THEN &
		Z0%(0%,2%)=P0% &
	  ELSE	Z%=Z0%(0%,2%) &
	\	Z%=Z0%(Z%,1%) WHILE Z0%(Z%,1%) &
	\	Z0%(Z%,1%)=P0% &
		! ZERO OUT THE 'JOB FLAG' AND 'QUEMAN SETUP LIST' &
		!  POINTER; &
		! FIND THE PLACE FOR A NEW JOB AND PUT IT THERE. &

24230	Z0%(P0%,1%),Z0%(P0%,27%)=0% &
	\ Z0%(P0%,31%)=R0% AND -225% &
	\ R0%=Z0%(P0%,31%) &
	\ F2%=F2% OR 2% &
	\ R%=R% OR 128% &
	\ GOTO 24550 &
		! ZERO OUT THE MAINPOINTER OF THE NEW JOB; &
		! RESET ALL BUILD-RELATED FLAGS; &
		! SET THE 'JOB READY' FLAG; &
		! GO USE THE COMMON EXIT. &
	&

24300	! &
	! &
	! &
	!	K I L L    J O B    R E C E I V E D    F R O M &
	!		Q U E M A N &

24310	IF J9% AND Z0%(J9%,17%)=2% THEN &
		GOSUB 21740 &
	\	Z0%(J9%,31%)=Z0%(J9%,31%) OR 16% &
	\	GOTO 24970 &
		! IF A JOB IS ACTIVE AND IT CAME FROM THE QUEUE, THEN &
		!	CALL THE ABORT ROUTINE; &
		!	SET THE 'BY QUEMAN' FLAG FOR THE ABORT MESSAGE; &
		!	GO EXIT. &

24320	Z%=Z0%(0%,16%) &
	\ IF Z% THEN &
		Z0%(0%,16%)=0% &
	  ELSE	Z%=Z0%(0%,2%) &
	\	Z1%=0% &
	\	WHILE Z% AND Z0%(Z%,15%)<>2% &
	\		Z1%=Z% &
	\		Z%=Z0%(Z%,1%) &
	\	NEXT &
	\	GOTO 24340 UNLESS Z% &
	\	IF Z1%=0% THEN &
			Z0%(0%,2%)=Z0%(Z%,1%) &
		ELSE	Z0%(Z1%,1%)=Z0%(Z%,1%) &
		! CHECK TO SEE IF PROGRAM IS BUILDING A QUEMAN JOB; &
		! IF SO, THEN &
		!	RESET THE 'QUEMAN BUILD POINTER'; &
		! ELSE	SCAN THE 'READY JOB LIST' FOR A JOB FROM &
		!	 THE QUEUE MANAGER; &
		!	GO ISSUE ERROR IF NONE FOUND; &
		!	OTHERWISE, LINK AROUND IT. &

24330	Z0%(Z%,1%)=0% \ Z%=FNA0%(Z%) \ GOSUB 20440 &
	\ GOTO 24970 &
		! RESET THE NEXT POINTER FOR THE ONE TO RETURN, RETURN &
		!  IT, SEND AN 'ENDJOB' PACKET TO QUEMAN; &
		! USE THE COMMON EXIT. &

24340	GOSUB 24500 &
	\ T$="KILL JOB" \ T1$="NO JOB RECEIVED FROM QUEUE" \ GOTO 24400 &
		! SYNCHRONIZATION ERROR : &
		! SET UP AS IF THE ENTRY HAD BEEN THROUGH THE COMMON &
		!  ENTRY ROUTINE; &
		! ISSUE IT AND EXIT. &
	&
	&

24400	! &
	! &
	! &
	!	S Y N C H R O N I Z A T I O N    E R R O R &
	&

24410	T$="SYNCHRONIZATION ERROR -"+C9$+T$+ &
		" RECEIVED FROM QUEMAN WHEN "+T1$ &
	\ T$=T$+C9$+"REQUESTING REQUE" IF (R% AND 8192%) &
	\ GOSUB 23500 &
	\ GOSUB 20420 IF (R% AND 8192%) &
	\ GOSUB 20440 IF (R% AND 8192%) &
	\ Z0%(0%,16%)=FNA0%(Z0%(0%,16%)) IF Z0%(0%,16%) &
	\ F2%=F2% OR 2% &
	\ GOTO 24550 &
		! SET UP MESSAGE AND ISSUE IT; &
		! IF THE PACKAGE IS ONLINE TO QUEMAN, THEN &
		!	ISSUE A REQUE REQUEST FOLLOWED BY AN ENDJOB; &
		! CLEAR THE BUILD LIST POINTER; &
		! EXIT THROUGH THE NORMAL COMMON EXIT ROUTINE. &
	&

24500	! &
	! &
	! &
	!	C O M M O N    E N T R A N C E    T O    Q U E M A N &
	!		P A C K E T    R O U T I N E S &
	&

24510	Z%=FNPUSH%(P0%) \ P0%=Z0%(0%,16%) &
	\ R0%=Z0%(P0%,31%) &
	\ R1%=Z0%(P0%,34%) &
	\ IF P0%=0% OR (R% AND 8192%)=0% THEN &
		T$="JOB-RELATED PACKET" &
	\	T1$="NOT SPOOLING" UNLESS (R% AND 8192%) &
	\	T1$="NOT REQUESTED" IF (R% AND 8192%) &
	\	P0%=0% &
		! PUSH THE CURRENT VALUE OF P0%, SET THE NEW VALUE TO &
		!  THE QUEMAN SET UP LIST'S JOB RECORD; &
		! PUSH THE CURRENT VALUE OF THE JOB'S PRW, HOLD THE PRW &
		!  OF THE JOB BEING SET UP; &
		! PUSH THE CURRENT VALUE OF THE JOB'S SWITCH &
		!  SPECIFICATION WORD, HOLD THAT OF THE JOB BEING SET &
		!  UP; &
		! IF NO JOB IS BEING BUILT OR THE JOB IS NO LONGER &
		!  ONLINE TO QUEMAN, THEN &
		!	SET UP AN APPROPRIATE SYNCHRONIZATION ERROR; &
		!	RESET THE BUILD LIST POINTER WORD TO FORCE &
		!	 PROCESSING OF THE ERROR UPON RETURN. &

24520	RETURN &
		! AND EXIT. &
	&

24550	! &
	! &
	! &
	!	C O M M O N    E X I T &
	&

24560	GOSUB 20360 IF (R0% AND 192%) &
	\ P0%=FNPOP% &
	\ R0%=Z0%(P0%,31%) &
	\ R1%=Z0%(P0%,34%) &
	\ GOTO 24970 &
		! GO REQUEST A 'NEXT PACKET' FROM QUEMAN IF STILL &
		!  LOOKING FOR FILE PACKETS; &
		! RESTORE THE PRW AND SSW TO THE RECORDS AND POP THEIR &
		!  OLD VALUES FROM THE STACK; &
		! POP THE OLD VALUE OF P0% FROM THE STACK; &
		! GO USE THE CLEAN UP EXIT TO GET RID OF THE MESSAGE. &
	&

24900	! &
	! &
	! &
	!	S O M E    C O M M O N    E R R O R S &
	&

24950	T$="JOB DID NOT COME FROM QUEUE FILE" &
	\ E%=-1% &
	\ GOTO 24970 &
		! COME HERE IF A QUEUE-TYPE REQUEST COMES IN FOR A JOB &
		!  WHICH DID NOT COME FROM THE QUEUE FILE. &

24960	T$="NO JOB ACTIVE" &
	\ E%=-1% &
	\ GOTO 24970 &
		! COME HERE IF A JOB MODIFICATION COMMAND COMES IN WHEN &
		!  NO JOB IS ACTIVE. &

24970	! &
	! &
	! &
	!	C O M M O N    E X I T &
	&

24980	ON ERROR GOTO 19000 &
		! RESET THE ERROR TRAP. &

24990	RETURN &
		! AND EXIT. &
	&
	&

25200	DEF* FNR%(S$,L%) &
	\ FNR%,Z1%=0% &
	\ Z0%=P% &
	! FUNCTION:	KEYWORD MATCHING ROUTINE. MATCHES A STRING IN &
	!		THE COMMAND STRING C$ STARTING AT POSITION P%+1% &
	!		TO THE DUMMY STRING S$. A MATCH IS MADE WHEN THE &
	!		MINIMUM NUMBER OF CHARACTERS ARE MATCHED. THIS &
	!		MINIMUM NUMBER IS HELD IN THE DUMMY VARIABLE &
	!		L%. &
	! PARAMETERS:	S$	STRING TO MATCH TO. &
	!		L%	MINIMUM LENGTH OF MATCH. &
	! GLOBAL &
	! VARIABLES &
	! AFFECTED:	P%	POSITION POINTER POINTS TO THE LAST CHAR- &
	!			ACTER MATCHED SUCCESSFULLY. &
	! LOCAL &
	! VARIABLES &
	! USED:		Z%	TEMPORARY CHARACTER POINTER. &
	!		Z$	CHARACTER MATCHING VARIABLE FOR PROCESS- &
	!			ING BEYOND THE MINIMUM LENGTH. &
	! RETURNS:	THE NUMBER OF CHARACTERS SUCCESSFULLY MATCHED. &
	! ERRORS:	NONE EXPECTED. &

25210	Z%=ASCII(RIGHT(C$,P%+1%)) &
	\ IF Z%=32% OR Z%=9% THEN P%=P%+1% &
				\ GOTO 25210 &
		! SKIP PAST BLANKS AND TABS. &

25220	IF MID(S$,1%,L%)=MID(C$,P%+1%,L%) THEN Z%=L% &
	ELSE GOTO 25250 &
		! SEARCH FOR MINIMUM MATCH. &

25230	Z$=MID(C$,P%+Z%+1%,1%) &
	\ IF Z$<>MID(S$,Z%+1%,1%) THEN GOTO 25240 &
	  ELSE Z%=Z%+1% UNLESS Z$=NULSTG$ &
	  \ GOTO 25230 UNLESS Z$=NULSTG$ &
		! SEARCH FOR MORE MATCHING CHARACTERS. &

25240	P%=P%+Z% &
	\ FNR%,Z1%=Z% &
		! RETURN WITH P% POINTING TO THE LAST SUCCESSFULLY &
		! MATCHED CHARACTER. FUNCTION WILL RETURN AS THE NUMBER &
		! OF CHARACTERS MATCHED. &

25250	P%=Z0% UNLESS Z1% &
	\ FNEND &
	&
	&
	&

25800	DEF* FNP%(P0%,P%,S$,Y0%,Y1%) &
	! FUNCTION:	FNP%	DO (NEW) FSS ON STRING S$, STARTING FROM &
	!			POSITION P%,AND RETURN THE DATA IN ARRAY &
	!			Z0%(P0%,X%), AND THE NEW CHARACTER POSITION &
	!			IN THE FUNCTION'S VALUE. &
	! PARAMETERS:	P0%	RECORD NUMBER IN Z0%(?,?) IN WHICH TO RETURN &
	!			THE DATA &
	!		P%	CHARACTER POSITION AFTER WHICH TO START THE &
	!			SCAN. &
	!		S$	STRING TO SCAN &
	!		Y0%	FIELD PROHIBIT WORD - SAME LAYOUT AS THAT &
	!			OF FLAG WORD 2 OF THE FSS SYS() CALL - &
	!			ANY BIT SET IN THIS WORD WHOSE CORRESPONDING &
	!			BIT IS SET IN THE FW2 RETURNED BY THE SYS() &
	!			CALL WILL RETURN E%=130%. &
	!		Y1%	DEVICE PROHIBIT/EXTRA FLAG/EXTRA SWITCH PROHIBIT &
	!			WORD - IF ANY BIT IS SET IN THIS WORD AND THE &
	!			CORRESPONDING BIT IS SET IN THE DEVICE HANDLER &
	!			INDEX (BITS 0-13) OF THIS WORD, E%=134% &
	!			IS RETURNED; IF ANY SUCH &
	!			CONDITION OCCURS IN THE TOP TWO BITS, &
	!			E% IS RETURNED AS 130%. &
	! GLOBAL VARIABLES EFFECTED: &
	!		E%	ERROR VALUE, IF ANY. &
	!		Z0%(P0%,X%) &
	!			THIS IS THE ULTIMATE PURPOSE OF THIS FUNCTION - &
	!			THIS WILL BE RETURNED AS AN INDEX-FILE FORMAT &
	!			REPRESENTATION OF THE SCANNED STRING. &
	!		Z%(30%)	USED FOR FSS FORMATTED STRING INTERMEDIATE &
	!			STORAGE; RETURNED IN THE SAME FORMAT AS THE &
	!			Z0%(P0%,X) ENTRY. &
	! LOCAL VARIABLES USED: &
	!		Z%	FOR LOOP COUNTER AND VARIOUS OTHER TEMPORARY &
	!			PURPOSES &
	!		Z1%(30%) &
	!			AS INTERMEDIATE STORAGE FOR THE STRING &
	!			RETURNED BY THE FSS CALL. &
	! RETURNS:	FNP%	POSITION OF THE CHARACTER AFTER THE LAST ONE &
	!			SCANNED.  IF ERROR (E%<>0%), THIS IS THE &
	!			SAME AS THE BEGIN POSITION ON ENTRY TO &
	!			THE FUNCTION (IE, P%, ABOVE). &
	! ERRORS EXPECTED: &
	!	E%=2	ILLEGAL FILENAME &
	!			IF THE FILENAME SPECIFIED DOES NOT &
	!			CONSTITUTE A VALID RSTS/E FILE SPEC. &
	!	E%=6	NOT A VALID DEVICE &
	!			IF THE DEVICE SPECIFIED IS INVALID. &
	!	E%=130	ILLEGAL FILENAME+ &
	!			IF SOME PROHIBITED FIELD, INCLUDING &
	!			ABSOLUTE DEVICE UNIT OR ANOTHER PPN, &
	!			WHEN PROHIBITED, WAS SPECIFIED. &
	!	E%=134	NOT A VALID DEVICE+ &
	!			WHEN A PROHIBITED DEVICE IS SPECIFIED. &
	&
	&

25810	ON ERROR GOTO 25880 &
	\ CHANGE SYS(CHR$(6%)+CHR$(-23%)+RIGHT(S$,P%+1%)) TO Z1% &
	\ Z1%(Z%)=Z1%(Z%)+SWAP%(Z1%(Z%+1%)) FOR Z%=1% TO 29% STEP 2% &
	\ FNP%=LEN(S$)-RECOUNT &
		! SET UP ERROR TRAP; DO THE SYS() CALL FOR FSS; &
		! PACK THE RETURNED DATA INTO THE ODD WORDS IN THE TEMP &
		! ARRAY; AND UPDATE CURRENT POSITION IN THE SOURCE &
		! STRING. &

25820	IF (Z1%(29%) AND -28672%)=4096% THEN &
		S$=CVT%$(SWAP%(Z1%(23%))) &
	\	S$=S$+FNU0$(Z1%(25%)) IF Z1%(25%)<0% &
	\	S$=MID(SYS(CHR6.M10$+S$+":"+S$),7%,4%) &
	\	Z1%(23%)=SWAP%(CVT$%(S$)) &
	\	Z1%(25%)=SWAP%(CVT$%(RIGHT(S$,3%))) &
		! IF DEVICE NAME EXISTS AND IS NOT LOGICAL (IE, ALREADY IN &
		! RAD50 FORM), THEN CONVERT IT TO RAD50 FORM USING THE &
		! FSS SYS() CALL. &

25830	Z%=(STATUS AND 255%)/2% &
	\ Z%=(2%^Z%) AND (Z1%(29%)>0%) AND 16383% &
	\ Z%=Z% OR NOT(32767%) IF &
		A%<>Z1%(5%) AND (A% AND -512%)<>0% &
		AND (Z1%(29%) AND 896%)=128% &
	\ Z%=Z% OR 16384% IF Z1%(26%)=255% AND (Z1%(29%)>0%) &
	\ Z1%(14%)=Z% &
		! SET UP FLAGS:	Z1%(14%) &
		!		LOW ORDER 14 BITS USED FOR BIT-ENCODED DHI; &
		!		TOP 2 BITS USED FOR FLAGS AS FOLLOWS: &
		!			-32768	ACCOUNT DOESN'T MATCH A% &
		!				AND A% IS NOT PRIV'D &
		!			16384	SPECIFIC DEVICE UNIT REQUESTED &
	&

25835	E%=130% IF (Y0% AND Z1%(29%))<>0% &
	\ E%=134% IF (Y1% AND Z1%(14%) AND 32767%)<>0% &
	\ E%=130% IF (Y1% AND Z1%(14%))<0% AND (STATUS AND 256%)=0% &
	\ GOTO 25890 IF E%<>0% &
		! CHECK FOR PROHIBITED SWITCHES, PROHIBITED DEVICES. &

25840	Z%(Z%)=0% FOR Z%=0% TO 30% &
	\ Z%(6%)=Z1%(23%) \ Z%(7%)=Z1%(25%) &
	\ Z%(8%)=Z1%(5%) &
	\ Z%(9%)=Z1%(7%) \ Z%(10%)=Z1%(9%) &
	\ Z%(11%)=Z1%(11%) &
	\ Z%(12%)=Z1%(21%) &
	\ Z%(13%)=Z1%(14%) &
	\ Z%(14%)=Z1%(29%) &
	\ Z%(16%)=Z1%(17%) AND 32767% &
	\ Z%(18%)=Z1%(15%) &
	\ Z%(19%)=Z1%(13%) &
	\ Z%(15%)=(Z1%(27%) AND 7%)*2048% &
	\ Z%=Z%(8%) &
	\ Z%(25%)=(255% AND (Z% AND 255%)<>255%) OR (-256% AND &
		(Z% AND -256%)<>-256%) &
		! SET UP ARRAY TO RETURN: &
		!	 DATA			WORD(S) &
		!	DEVICE NAME		6,7 &
		!	ACCOUNT			8 &
		!	FILENAME (2 WORDS)	9,10 &
		!	EXTENSION		11 &
		!	PROT/STATUS		12 &
		!	DHI AND FLAGS		13 &
		!	FLAG WORD 2		14 &
		!	/MO/CL/FI FLAGS		15 &
		!	/MODE VALUE		16 &
		!	/CLUSTERSIZE VALUE	18 &
		!	/FILESIZE VALUE		19 &
		! SET UP SELECTION SPECIFICATION WORD WITH THE &
		! MODE, CLUSTERSIZE, AND FILESIZE FLAGS AS RETURNED &
		! FROM FILENAME STRING SCAN; &
		! SET UP ACCOUNT SELECTION WORD FOR FUNNY ALGORITHM &
		! FOR ACCOUNT SELECTION. &

25850	IF P0%>-1% THEN &
		Z0%(P0%,Z%)=Z%(Z%) FOR Z%=6% TO 19% &
	\	Z0%(P0%,25%)=Z%(25%) &
		! PUT THE RESULT IN THE WORK-FILE UNLESS INSTRUCTED &
		! OTHERWISE (IE, UNLESS P0%<0%). &

25860	ON ERROR GOTO 19000 &
		! RESET ERROR TRAP. &

25870	FNEND &
		! AND WE'RE DONE. &
	&

25880	E%=ERR &
		! SOME FILENAME ERROR. &

25890	Z0%(P0%,0%)=0% UNLESS P0%<0% &
	\ FNP%=P% &
	\ RESUME 25860 &
		! SET UP ERROR NUMBER AND BEGIN POSITION OF STRING IN &
		! ERROR. &
	&
	&
	&
	&

25900	DEF* FNU$(P0%,C$,Z%,Z0%) &
	! FUNCTION :	FNU$	TURN A FILE DESCRIPTOR RECORD INTO &
	!			AN OPENABLE FILENAME STRING. &
	! PARAMETERS :	P0%	RECORD IN WORK-FILE TO CHANGE &
	!		C$	DUMMY STRING TO USE IN CONSTRUCTING &
	!			THE FILENAME STRING. &
	!		Z%	FLAG WORD 2 FORMAT WORD SHOWING WHICH &
	!			FIELDS IN THE RECORD TO CONVERT. &
	!		Z0%	WORD SHOWING WHICH SWITCHES TO CONVERT &
	!			(OF /MODE, /CLU, AND /FILESIZE). &
	! RETURNS :	FUNCTION VALUE &
	!			THE STRING TO USE IN AN OPEN. &
	! USES :	FNU0$(L%) &

25910	Z%=Z% AND Z0%(P0%,14%) &
	\ Z%=Z% AND -3201% IF (Z0%(P0%,13%) AND 1914%) &
		IF Z0%(P0%,14%)>0% &
	\ C$="" &
		! CREATE A WORD (Z%) WHICH HAS BITS SET FOR A FIELD ONLY &
		! IF THAT FIELD IS BOTH REQUESTED AND PRESENT IN THE &
		! DATA; &
		! IF DEVICE IS NOT DISK, DT, MT, OR LOGICAL, DO NOT &
		! RETURN FILENAME, EXTENSION; &
		! INITIALIZE THE STRING TO NULL. &
	&

25920	C$=RAD$(Z0%(P0%,6%))+RAD$(Z0%(P0%,7%))+":" IF (Z% AND 4096%) &
	\ C$=C$+"["+FNU0$(SWAP%(Z0%(P0%,8%)))+","+FNU0$(Z0%(P0%,8%))+ &
		"]" IF (Z% AND 128%) &
	\ C$=C$+RAD$(Z0%(P0%,9%))+RAD$(Z0%(P0%,10%)) IF (Z% AND 1%) &
	\ C$=C$+"."+RAD$(Z0%(P0%,11%)) IF (Z% AND 8%) &
	\ C$=C$+"<"+FNU0$(SWAP%(Z0%(P0%,12%)))+">" IF (Z% AND 3072%) &
		! SET UP Z% AS BITS SET IN BOTH THE REQUESTED ENTRY &
		! WORD AND THOSE SET IN THE ACTUAL FILENAME STRING. &
		! IF DEV: REQ/EXSTS, MAKE IT; &
		! IF [PPN] REQ/EXSTS, MAKE IT; &
		! IF FILENAME REQ/EXSTS, MAKE IT; &
		! IF .EXT REQ/EXSTS, MAKE IT; &
		! IF <PROT> REQ/EXSTS, MAKE IT. &

25930	Z0%=Z0% AND Z0%(P0%,15%) AND 14336% &
	\ IF Z0% THEN &
		C$=C$+"/CL:"+NUM$(Z0%(P0%,18%)) IF (Z0% AND 2048%) &
	\	C$=C$+"/MO:"+NUM$(Z0%(P0%,16%)) IF (Z0% AND 4096%) &
	\	C$=C$+"/FI:"+NUM$(Z0%(P0%,19%)) IF (Z0% AND 8192%) &
		! SET UP Z0% TO HOLD ONLY THE FLAGS SET BOTH IN THE &
		! OPEERAND IN THE CALL AND IN THE RECORD POINTED TO; &
		! PUT THE "/SWITCH:OPERAND" STRINGS INTO THE RETURNED &
		! STRING IN THE ORDER: &
		!	2048	CLUSTERSIZE &
		!	4096	MODE &
		!	8192	FILESIZE &

25960	FNU$=C$ &
		! SET FUNCTION VALUE. &

25970	FNEND &

25980	DEF* FNU0$(L%) &
	\ L%=L% AND 255% &
	\ IF L%=255% THEN FNU0$="*" ELSE FNU0$=NUM1$(L%) &
		! TAKE THE LOW BYTE OF L%; &
		! IF THAT BYTE IS 255, THEN &
		!	RETURN '*'; &
		! ELSE	RETURN NUM1$ OR BYTE. &

25990	FNEND &
	&
	&
	&

26100	DEF* FNA% &
		! RETURN SUBSCRIPT OF NEXT FREE INDEX ENTRY AND ZERO &
		!  THAT ENTRY. &
		! PARAMETERS:	NONE &
		! RETURNS:	SUBSCRIPT OF THE FIRST ENTRY IN THE FREE &
		!		SPACE LIST. &
		! USES:	Z%	LOOP VARIABLE FOR ZEROING &
		! NOTES:	USES FREE LIST POINTER OUT OF THE INDEX &
		!		 FILE &
		!		HEADER TO GET SUBSCRIPT.  IF FL POINTER &
		!		 IS NEGATIVE, THAT PART OF THE FILE HAS &
		!		 NOT YET BEEN INITIALIZED, AND THE &
		!		 ROUTINE WILL GO TO DO IT. THEN THE &
		!		 ENTRY TO BE RETURNED IS ZEROED. &

26110	B0%=Z0%(0%,0%) IF B0%=0% &
	\ Z0%=B0% &
	\ IF Z0%<0% THEN &
		Z0%=-Z0% &
	\	Z0%(Z%,1%)=Z%+1% FOR Z%=Z0% TO Z0%+7% &
	\	Z0%(Z%,1%)=-Z%-1% &
		! GET NEXT FREE LIST ENTRY; &
		! IF SUBSCRIPT IS NEGATIVE, THIS ENTRY HAS NOT YET BEEN &
		! TOUCHED, SO EXTEND A FEW. &

26120	B0%=Z0%(Z0%,1%) &
	\ Z0$(Z0%)=NULSTG$ &
	\ FNA%=Z0% &
		! ZERO OUT THE RETURNED ENTRY AND SET FUNCTION VALUE. &

26130	FNEND &
		! END OF FNA%. &
	&

26200	DEF* FNA0%(P0%) &

26210	Z0%,Z2%=P0% &
	\ Z0%=Z0%(Z0%,1%) WHILE Z0%(Z0%,1%) &
	\ FOR Z%=2% TO 5% &
	\	Z2%=P0% &
	\	WHILE Z2% &
	\		IF Z0%(Z2%,Z%) THEN &
				Z3%=Z0%(Z2%,Z%) &
	\			Z0%(Z2%,Z%)=0% &
	\			Z0%,Z0%(Z0%,1%)=Z3% &
	\			Z0%=Z0%(Z0%,1%) WHILE Z0%(Z0%,1%) &

26220			Z2%=Z0%(Z2%,1%) &
	\	NEXT &
	\ NEXT Z% &
	\ Z0%(Z0%,1%)=B0% &
	\ B0%=P0% &
	\ FNA0%=0% &

26230	FNEND &
	&

27000	DEF* FNCHNGE%(S$) &
	&
	\ CHANGE S$ TO Z% &
	\ Z%(Z%)=0% FOR Z%=Z%(0%)+1% TO 30% &
	\ Z%(Z%)=Z%(Z%)+SWAP%(Z%(Z%+1%)) FOR Z%=1% TO Z%(0%) STEP 2% &
	\ FNCHNGE%=0% &
	&
	\ FNEND &
	&
	!  FUNCTION :	CHANGE THE STRING S$ INTO THE INTEGER ARRAY &
	!		Z%(30%), PADDING TO 30 CHARACTERS WITH 0, AND &
	!		CONVERT EACH TWO BYTES TO ONE INTEGER. &
	! &
		! CHANGE THE STRING; &
		! PAD OUT TO 30; &
		! DO THE SWAP/ADDS; &
		! SET A FUNCTION VALUE. &
	&

27200	DEF* FNN% &
	\ FNN%,F%=0% &
	! FUNCTION:	RETURN A NUMBER ROUTINE. &
	! PARAMETERS:	NONE &
	! GLOBAL &
	! VARIABLES &
	! AFFECTED:	P%	CHARACTERS POSITION POINTER. &
	!		F%	FOUND FLAG. &
	! LOCAL &
	! VARIABLES &
	! USED:		Z%	TEMPORARY POSITION POINTER. &
	!		Z0%	ASCII CHARACTER REPRESENTATION. &
	! RETURNS:	VALUE OF NUMERIC DIGITS FOLLOWING POSITION P% &
	!		IN THE STRING C$. IF NONE ARE FOUND THE FOUND FLAG &
	!		IS RETURNED AS ZERO. &
	! ERRORS:	NONE EXPECTED. &

27210	ON ERROR GOTO 27250 &
	\ Z%=P%-1% &
	\ Z0%=-1% &
		! SET LOCAL ERROR HANDLER. &
		! SET LOCAL CHARACTER POINTER. &
		! INITIALIZE ASCII DIGIT FLAG. &

27220	WHILE (Z0%>=48% AND Z0%<=57%) OR Z0%=-1% &
		\ Z%=Z%+1% &
		\ Z0%=ASCII(RIGHT(C$,Z%+1%)) &
	\ NEXT &
		! CHECK FOR DIGITS, AND EXIT HERE WITH Z%=P% OR Z% &
		! POINTING TO THE LAST DIGIT FOUND. &

27230	IF Z%<>P% THEN FNN%=VAL(MID(C$,P%+1%,Z%-P%)) &
				\ P%=Z% &
				\ F%=-1% &
		! WE HAVE FOUND A NUMBER. SET THE FUNCTION VALUE TO &
		! THE VALUE OF THE NUMBER FOUND AND SET THE FOUND FLAG. &

27240	ON ERROR GOTO 19000 &
	\ FNEND &
		! RESET THE ERROR HANDLER. &
		! CHECK TO SEE IF THERE WAS AN ERROR. &
		! RETURN. &

27250	E%=564% IF ERR/10%=5% &
	\ RESUME 27240 &
		! TRAP ERRORS IN THE VAL FUNCTION. &
	&

27300	DEF* FNUNPACK$(P0%,P1%) &
	! FUNCTION :	FNUNPACK$	UNPACK A STRING OUT OF THE WORK- &
	!				 FILE AND RETURN THE STRING IN &
	!				 THE FUNCTION VALUE. &
	! OPERANDS :	P0%		THE HEAD RECORD OF THE LIST OF &
	!				 RECORDS CONTAINING THE STRING. &
	!		P1%		THE NUMBER OF BYTES TO SKIP AT &
	!				 THE BEGINNING OF THE FIRST &
	!				 RECORD - THESE BYTES ARE &
	!				 SKIPPED IN ORDER TO LEAVE ROOM &
	!				 FOR CONTROL INFORMATION, SUCH &
	!				 SOURCE OF MESSAGE, PPN FROM &
	!				 WHICH IT CAME, DISPATCH CODE, &
	!				 ETC. &
	! RETURNS :	THE UNPACKED STRING IN THE FUNCTION VALUE. &
	&

27310	Z%=Z0%(P0%,P1%/2%) &
	\ P1%=P1%+3% &
	\ Z9%=P0% &
	\ Z8%=Z0%(P0%,1%) &
	\ Z0%(P0%,1%)=Z0%(P0%,2%) \ Z0$=NULSTG$ &

27320	Z0%=129%-P1% \ Z0%=Z% IF Z0%>Z% &
	\ Z$=RIGHT(Z0$(P0%),P1%) &
	\ Z$=Z$+STRING$(Z0%-LEN(Z$),0%) &
	\ Z%=Z%-LEN(Z$) &
	\ Z0$=Z0$+Z$ &
	\ P1%=Z0%(P0%,1%) &
	\ IF P1% THEN &
		P0%=P1% &
	\	P1%=13% &
	\	GOTO 27320 &

27330	Z0%(Z9%,1%)=Z8% &
	\ FNUNPACK$=Z0$ &

27340	FNEND &
	&

27400	DEF* FNPUSH%(VALUE%) &
	&
	\ S%=S%+1% \ S%(S%),FNPUSH%=VALUE% &
	&
	\ FNEND &

27410	DEF* FNPOP% &
	&
	\ FNPOP%=S%(S%) \ S%=S%-1% &
	&
	\ FNEND &
	&
	&
	&

31000	! &
	! &
	! &
	!	C H A I N    E N T R Y &
	&

31010	E0%=2% &
	\ C$=SYS(CHR$(7%)) &
	\ B%=CVT$%(C$) &
	\ W$=RIGHT(C$,3%) &
	\ GOTO 1000 &
		! TAKE THE FHR AND THE WORK-FILE &
		!  NAME OUT OF CORE COMMON AND GO TO WORK. &
	&

32767	END
