	.TITLE	SCHED  --  SCHEDULE SETUP PROGRAM FOR RSX/BATCH
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/
/	SCHED FUNCTION TASK
/	EDIT #1  1/30/74  G. COLE
/
/
/	SCHED IS CALLED BY OPR TO SETUP A SCHEDULE TABLE
/		FROM A FILE OR FROM THE OPERATOR AT THE TERMINAL.
/
/	THIS TASK IS INDENDED TO BE NAMED SC.OPR
/		AND MUST RUN IN EXEC MODE.
/
/	TYPICAL SEQUENCE IS:
/
/	OPR>SCH
/	*NAME
/	TF=23 CF=2 WF=1 TM=2 CM=0 WM=60
/
/	NAME IS THE NAME OF THE SCHEDULE FILE WHOSE EXTENSION IS
/	SCH( IE, IN THE EXAMPLE FILE NAME SCH WOULD BE READ)
/
/	ANOTHER EXAMPLE:
/
/	OPR>SCH
/	*  TM=25
/
/	HERE THE USER SET THE MAXIMUM EXTIMATED JOB TIME TO 25 MIN
/	THE PRESENCE OF AN = IN THE EXPRESSING SIGNALS THAT THIS IS 
/	A DIRECT COMMAND AND NOT A FILE NAME. THUS FILE NAMES
/	MAY NOT BE USED WHICH HAVE EMBEDDED = SIGNS.
/
/
/
/	THE THIRD LINE IS THE CONTENETS OF THE SCHEDULE FILE
/	(ONE LINE ONLY IS USED).
/
/
/	IN A NORMAL ENVIRONMENT THERE WOULD BE
/	A FILE CORESPONDING TO EACH MAJOR PERIOD OR MODE OF 
/	SYSTEM OPERATION.(IE. MORN SCH,NOON SCH,WEEK SCH   ETC)
/
/	THE SCHEDULE MAY BE SE AT ANY TIME THAT BATCH IS RUNNING
/	BY INVOKING THIS TASK.
/
/
	.EJECT
/DEFINE THE PRINT MACRO USED HERE AND IN QUEUE AND OPR
	.DEFIN PRINT,ZLUN,ZA,ZB,ZC,ZD,ZE,ZF
	CAL	.+3
	CAL	.+10
ZTMP2=.
	HLT
	2700
	.+4
	ZLUN
	2
	.+4
	0
	20
	.-2
ZTMP=.
	0
	0
	.ASCII	"ZA ZB ZC ZD ZE ZF"<015>
ZTMP1=.
	.LOC	ZTMP
	ZTMP1-ZTMP/2*1000+2
	.LOC	ZTMP2
	JMP	ZTMP1
	.LOC	ZTMP1
	.ENDM
/
/	DEFINE PARAMETERS
	.IFUND	TTYLUN
TTYLUN=100		/LUN 64 IS THE BATCH CONSOLE
	.ENDC
	.IFUND	STKLUN
STKLUN=12
	.ENDC		/LUN 10 IS THE STACKING LUN
BCV=147
	.GLOBL	FAC57,SET57
TTLUN=TTYLUN
	.EJECT
/
/CODING TO GET THE USER TO INPUT A LINE
/
/PROMPT THE USER WITH AN ASTERICK AND WAIT
START	CAL	PROMPT
	CAL	WAITLL	/PRINT AN *
	LAC	EVL
	SPA		/WAS THAT OK
	JMP	CMDERR
	CAL	RCMDL	/READ COMMAND LINE
	CAL	WAITLL
	LAC	EVL
	SPA
	JMP	CMDERR
/
/	PREPARE THE LINE TO BE SCANNED
/
	JMS*	SET57
	LINBF
	JMP	SCPRO	/PROCESS THE COMMAND
/
/DEFINE NECESARY ROUTINES AND CPBS
/
GETC	0	/ROUTINE TO GET A CHAR
	JMS*	FAC57
	SAD	(15)
	JMP*	GETC
	SAD	(175)
	JMP*	GETC
	ISZ	GETC
	JMP*	GETC	/THIS ROUTINE RETURNS TO CALL+1 ON EOL
			/AND CALL+2 ON NOT EOL WITH CHAR IN AC
			/IN ALL CASES
/
PROMPT	2700	/WRIT
	EVL
	TTLUN
	3
	.+1
	002003
	0
	15
	52		/CPB TO PRINT CR,ASTERICK
WAITLL	20
	EVL
EVL	0
USRF	0	/SET TO ALLOW USER INPUT
/
RCMDL	2600		/CPB TO READ AL INE INTO LINBF
	EVL
	TTLUN
	2
	LINBF
	60
LINBF	.BLOCK	60	/LINE BUFFER FOR COMMAND
/
CMDERR	PRINT	TTLUN,I/O,ERROR,TO,TERMINAL
	CAL	(10)
	.EJECT
/
/
/
SCPRO	LAC*	(BCV)	/IS BATCH RUNNING
	SNA
	JMP	BNRERR	/NO, TELL OPR AND QUIT
	LAC	(SNB-1)	/SETUP BUFFER FOR FILE NAME
	DAC*	(10)
	LAW	-6
	DAC	SCCNT	/COUNT FOR CHAR IN FILE NAME
	ISZ	USRF	/SET USER FLAG, WILL CAUSE USER INPUT
			/IF NULL LINE
 
SCSHR	JMS	GETC
	CAL	(10)	/EXIT IF EMPTY COMMAND
	SAD	(40)	/SCAN OFF BLANKS
	JMP	SCSHR
 
SCLOOP	SAD	(075)	/TEST FOR =
	JMP	SCUPK	/REPROCESS LINE AS A DIRECT SPECIFICATION
	DAC*	10	/STORE CHAR IN FILE NAME BUFFER
	JMS	GETC	/GET NEXT CHR
	JMP	SCASM	/GOT LAST ONE
	ISZ	SCCNT	/IS THIS 6
	JMP	SCLOOP	/NO
 
SCASM	LAC	SNB+5	/ASSEMBLE FILE NAME
	LRS	6
	LAC	SNB+4
	LRS	6
	LAC	SNB+3
	LLS	14	/SECOND HALF
	DAC	SCFIL2
	DAC	SCCFL2
 
	LAC	SNB+2	/ASSEMBLE FILE NAME
	LRS	6
	LAC	SNB+1
	LRS	6
	LAC	SNB
	LLS	14	/FIRST HALF
	DAC	SCFIL1
	DAC	SCCFL1	/INTO APPROPRIATE CPBS
 
	CAL	SCOPN	/OPEN THE FILE
	CAL	WAITLL
	LAC	EVL		/TRY TO GET THE SCHEDULE FIE
	SPA
	JMP	SCFNF		/ERROR IF NOT OK
	JMP	SCANL		/ANALYZE THE LINE
	.EJECT
SCANL	CAL	SCREAD		/READ THE LINE
	CAL	WAITLL
	LAC	EVL
	SPA			/TEST FOR OK
	JMP	SCRERR	/READ ERROR
	CAL	SCWRIT	/WRITE LINE TO USER
	CAL	WAITLL
 
SCUPK	JMS*	SET57		/PROEPARE LINE FOR SCANNING
	LINBF
 
SCSCN	JMS	GETC
	JMP	SCDONE		/IF EMPTY LINE 
	SAD	(40)		/IGNORE SAPCES AND COMMAS
	JMP	SCSCN
	SAD	(54)
	JMP	SCSCN
	DAC	SNB
	JMS	GETC
	JMP	SCFERR		/ERROR IF NOT HERE
	DAC	SNB+1
	JMS	GETC
	JMP	SCFERR
	DAC	SNB+2
	LAC	SNB
	LRS	6
	LAC	SNB+1
	LRS	6
	LAC	SNB+2
	LLS	14
	DAC	SCNAM
	DZM	SCVAL		/PROPARE TO READ IN A NUMBER
	.EJECT
SCDIS	JMS	GETC	/GET FIRST CHAR
	JMP	SCFERR 
	AAC	-60	/TEST FOR DIGIT
	SPA
	JMP	SCFERR
	DAC	SCDIG	/SAVE, MAY BE GOOD
	AAC	-12
	SMA
	JMP	SCFERR	/NO ... ALAS IT IS NOT A DIGIT
 
	LAC	SCVAL	/MUL VAL*10 ADD DIG TO VAL
	LMQ
	MUL; 12
	LACQ
	TAD	SCDIG
	DAC	SCVAL	/SAVE VALUE AS RUNNING VALUE
 
	JMS	GETC	/GET NEXT DIGIT
	JMP	SCSTR	/STORE VALUE IF END
	SAD	(40)
	JMP	SCSTR	/STORE VALUE
	SAD	(54)
	JMP	SCSTR	/STORE VALUE
	JMP	SCDIS+2	/PROCESS NEXT AS A DIGIT
	.EJECT
/
/
/AT THIS POINT WE HAVE SCNAM CONTAINING THE TYPE OF THE ITEM
/AND SCVAL CONTAINING THE VALUE OF THE ITEM.
/
/PUT THE ITEM INTO ITS PLACE INT THE BCV.
/
SCSTR	LAC	SCNAM
	SAD	SCTF
	JMP	SCTFX	/SET TIME FACTOR
	SAD	SCWF
	JMP	SCWFX	/SET WAIT FACTOR
	SAD	SCCF
	JMP	SCCFX	/SET CLASS FACTOR
	SAD	SCTM
	JMP	SCTMX	/SET MAXIMUM TIME
	SAD	SCWM
	JMP	SCWMX	/SET MAXIMUM WAIT
	SAD	SCCM
	JMP	SCCMX	/SET  MININUM CLASS
		/IF YOU NEED TO ADD NEW FUNCTIONS PUT THEM IN HERE
	JMP	SCTERR
 
SCTFX	LAW	-1	/WORD 1 IN BCV IS TIME FACTOR
	JMP	SCSTV
 
SCCFX	LAW	-2
	JMP	SCSTV
 
SCWFX	CLA
	JMP	SCSTV
 
SCTMX	LAW	-10
	JMP	SCSTV
 
SCCMX	LAW	-11
	JMP	SCSTV
 
SCWMX	LAW	-7
	JMP	SCSTV
 
SCSTV	TCA	/GET POSITIVE CONSTANT
	DAC	SCTEMP
	LAC*	(BCV)
	SNA		/IS BATCH STILL RUNNING
	JMP	BNRXXX
	TAD	SCTEMP
	DAC	SCTEMP
	LAC	SCVAL
	DAC*	SCTEMP
	JMP	SCSCN	/GET NEXT ITEM AND PUT IT AWAY
 
BNRXXX	CAL	SCCLS
	CAL	WAITLL
	JMP	BNRERR	/CLOSE FIE AND PRINT ERROR
 
SCDONE	CAL	SCCLS
	CAL	WAITLL
	CAL	(10)	/QUIT AFTER CLOSING FILE
	.EJECT
/DEFINE VARIABLES AND TABLES
SCVAL	0	 /HOLD PARAMETER VALUE
SCDIG	0
SCTEMP	0
SCNAM	0	/HOLDS PARAMTER NAME
 
/LIST OF PARAMETER NAMES
 
SCTF	.SIXBT	/=FT/
SCWF	.SIXBT	/=FW/
SCCF	.SIXBT	/=FC/
SCTM	.SIXBT	/=MT/
SCWM	.SIXBT	/=MW/
SCCM	.SIXBT	/=MC/
 
/DEFINE FILES CPBS
 
SCOPN	3200	/SEEK FILE
	EVL
	STKLUN
SCFIL1	0
SCFIL2	0
	.SIXBT	/SCH/
 
SCCLS	3400	/CLOSE FILE
	EVL
	STKLUN
SCCFL1	0
SCCFL2	0
	.SIXBT	/SCH/
 
SCREAD	2600	/READ LINE
	EVL
	STKLUN
	2
	LINBF
	60
 
SCWRIT	2700
	EVL
	TTLUN
	2
	LINBF
 
SCCNT	0
SNB	0
	0	/FILE NAME BUFFER
	0
	0
	0
	0
	0
	.EJECT
FMTERR	PRINT	TTLUN,COMMAND,FORMAT,ERROR
	CAL	(10)
SCFNF	PRINT	TTLUN,SCH,FILE,NOT,FOUND
	CAL	(10)
SCRERR	PRINT	TTLUN,SCH,READ,ERROR
	JMP	SCDONE
SCFERR	PRINT	TTLUN,SCH,FORMAT,ERROR
	JMP	SCDONE
SCTERR	PRINT	TTLUN,INCORRECT,PARAMETER,TYPE
	JMP	SCDONE
BNRERR	PRINT	TTLUN,BATCH,NOT,RUNNING
	CAL	(10)
	.END
