	.TITLE	HOTNWS
/
/   8 JUL 76 - PAUL HENDERSON
/
/  TASK TO PRINT A MESSAGE ON THE LINE PRINTER
/
	.DEC
LP=16
RK=17
	.OCT
/
HOTNWS	DZM	FCN		/ INITIALIZE DISPATCH FUNCTION
	HINF	LP,EV
	JMS	WAIT
	SPA			/ MAKE SURE WE HAVE GOOD RESPONSE
	CAL*			/ TERMINAL ERROR IF NOT
	AND	(100007
	SAD	(100001
	SKP
	CAL*			/ NOT SUITABLE DEVICE
	ATTACH	LP,EV		/ EITHER LP OR TTY
	JMS	WAIT
	SPA
	CAL*			/ UNSUCCESSFUL ATTACH FOR SOME REASON
	SEEK	RK,STARS,MSG,EV
	JMS	WAIT
	SPA
	CAL*			/ FILE NOT FOUND!
	WRITE	LP,2,FF,EV
	JMP	WAITLP
/
LOOP1	READ	RK,2,LINE,52,EV
	JMS	WAIT
	SPA
	CAL*
	LAC	LINE		/ END OF FILE?
	AND	(7
	SAD	(2
	SKP
	JMP	NEXT		/ YES.  PERFORM NEXT FUNCTION
	WRITE	LP,2,LINE,EV
WAITLP	JMS	WAIT
	SMA
	JMP	LOOP1
	CAL*
/
NEXT	LAC	FCN		/ FIND OUT WHERE WE GO NEXT
	SNA
	JMP	MAIN
	SAD	(1
	JMP	TRAIL
	SAD	(2
	JMP	FLUSH
	JMP	DONE
/
MAIN	CLOSE	RK
	SEEK	RK,HOTNWS,MSG,EV
	JMS	WAIT
	SPA
	CAL*			/ FILE NOT FOUND.  TERMINAL ERROR
	CLA!IAC
	DAC	FCN		/ SET FCN=1
	JMP	LOOP1		/ OUTPUT MAIN BODY OF MESSAGE
/
TRAIL	CLOSE	RK
	SEEK	RK,STARS,MSG,EV
	JMS	WAIT		/ ASSUME IT IS THERE (IT WAS LAST TIME)
	LAC	(2
	DAC	FCN
	JMP	LOOP1
/
FLUSH	CLOSE	RK
	SEEK	RK,FF,SRC,EV
	JMS	WAIT
	SPA
	CAL*
	LAC	(3
	DAC	FCN
	JMP	LOOP1		/ OUTPUT FLUSH FILE
/
DONE	CLOSE	RK
	DETACH	LP,EV		/ DONE WITH LINE PRINTER
	JMS	WAIT		/ WAIT FOR DETACH, BUT DON'T CARE ABOUT STATUS
	CAL	(10		/ EXIT
/
WAIT	XX
	CAL	WAITF
	LAC	EV
	JMP*	WAIT		/ LEAVE WITH EV IN AC
/
WAITF	20
	EV
/
FCN;EV
/
LINE	.BLOCK	100
FF	2002; 0
	.ASCII	<14><175>
	.END	HOTNWS
