	.TITLE *** TDV FUNCTION "DELETE"
/ 
/ 
/                   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
/
/	EDIT #16	30 APR 72	C. PROTEAU
/
/ COPYRIGHT 1971, 1972, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ TDV (TASK DEVELOPMENT) TASK, NAMED "DEL...", FOR DELETING FILES FROM
/ THE DISK VIA "LUN".
/
/////////////////////////////////////////////////////////
/							/
/ COMMAND STRING EXAMPLE:				/
/							/
/	TDV>DEL FILE1,FILE2,FILE3			/
/							/
/	TDV>DEL FILE1 SRC,FILE2 BIN,FILE3 003		/
/							/
/////////////////////////////////////////////////////////
/
/ THE FILE NAME EXTENSION IS OPTIONAL -- "SRC" IS THE DEFAULT ASSUMPTION.
/
/ THE COMMAND INPUT LINE IS READ BY THE RESIDENT TDV TASK ("TDV...") AND
/ IS TRANSFERRED TO THIS TASK BY MEANS OF THE XFRCMD DIRECTIVE.
/
/	COMMAND SYNTAX = 'DEL'$<NSP><SP><FILE NAME>((<SP><EXT>)/)
/			 $(<COM><FILE NAME>((<SP><EXT>)/))(<CR>/<AM>)
/
/	<NSP> = NON-SPACE CHARACTER
/	<SP>  = A SPACE CHARACTER
/	<FILE NAME> = 1 TO 6 ALPHANUMERIC CHARACTERS
/	<EXT> = 1 TO 3 ALPHANUMERIC CHARACTERS
/	<COM> = A COMMA
/	<CR>  = A CARRIAGE RETURN
/	<AM>  = AN ALTMODE
/	$<..> OR $(..) = ANY NUMBER, INCLUDING NONE, OF THE ITEM <..> OR (..).
/
/ AT COMPLETION OF THE DELETE FUNCTION, THE TERMINATING CHARACTER OF THE
/ COMMAND LINE IS EXAMINED. IF IT IS A CARRIAGE RETURN, THE RESIDENT TDV
/ TASK IS "REQUESTED" AND "DELETE" EXITS. IF THE LINE IS TERMINATED BY AN
/ ALTMODE, "DELETE" EXITS WITHOUT "REQUESTING" "TDV...". A CTRL T TYPEIN
/ IS THEN NECESSARY TO RE-ESTABLISH TDV DIALOGUE.
/
	.DEC
LUN=17				/LUN NORMALLY ASSIGNED TO DISK.
TDVTTY=13			/TDV TTY ERROR LUN.
	.OCT
X10=10				/AUTOINCREMENT REGISTER 10.
IDX=ISZ				/USED WHEN THE SKIP IS NOT INTENDED.
CBFSIZ=40			/SIZE OF THE COMMAND LINE BUFFER FOR UP
				/TO 80 CHARACTERS.
/
	.EJECT
DEL	CAL	XFER		/TRANSFER THE COMMAND LINE READ BY "TDV...".
	CAL	WAITFR
	LAW	-16		/IS THE BUFFER TOO SMALL, I.E., IS THE
	SAD	EV		/COMMAND LINE TOO LONG?
	JMP	ERR1		/YES.
/
/ INITIALIZE THE FETCH-A-CHARACTER SUBROUTINE. THIS MUST BE DONE HERE,
/ RATHER THAN BEING ASSEMBLED IN, IN CASE THE TASK IS FIXED IN CORE AND
/ IS THUS NOT REINITIALIZED.
/
	LAC	(FACLB+2)
	DAC	FACLBX
	LAC	(FACCB+5)
	DAC	FACCBX
/
/ FLUSH COMMAND INPUT THROUGH THE FIRST BREAK CHARACTER.
/
FLUSH	JMS	FAC		/FETCH A CHARACTER FROM COMMAND LINE.
	SAD	(40)		/SPACE?
	JMP	NEXFIL
	SAD	(15)		/CARRIAGE RETURN?
	SKP
	SAD	(175)		/ALTMODE?
	JMP	ERR2		/SYNTAX ERROR.
	JMP	FLUSH
/
/ UNPACK THE FILE NAME.
/
NEXFIL	LAC	(BUF-1)		/INITIALIZE THE NAME BUFFER.
	DAC*	(X10)
	LAW	-7		/UNPACK FILE NAME (UP TO 6 CHARACTERS).
	JMS	UNPACK		/RETURN IF NO ERROR OCCURRED.
/
/ CONVERT THE FILE NAME TO .SIXBT AND STORE IT IN THE DELETE CPB.
/
	.DEC
	LAC	BUF+2
	LRS	6
	LAC	BUF+1
	LRS	6
	LAC	BUF+0
	LLS	12
	SNA
	JMP	ERR2		/SYNTAX ERROR -- NULL FILE NAME.
	DAC	DELETE+3
	LAC	BUF+5
	LRS	6
	LAC	BUF+4
	LRS	6
	LAC	BUF+3
	LLS	12
	DAC	DELETE+4
	.OCT
/
/ THE FILE NAME EXTENSION IS OPTIONAL; THE DEFAULT EXTENSION IS "SRC".
/ VALIDATE THE DELIMITER.
/
	LAC	CHAR
	SAD	(15)		/CARRIAGE RETURN?
	SKP
	SAD	(175)		/ALTMODE?
	SKP
	SAD	(54)		/COMMA?
	JMP	USESRC		/ASSUME DEFAULT "SRC" EXTENSION.
	SAD	(40)		/SPACE?
	SKP
	JMP	ERR2		/NO -- ILLEGAL DELIMITER.
/
/ UNPACK THE FILE NAME EXTENSION.
/
	LAW	-4		/UNPACK EXTENSION (UP TO 3 CHARACTERS).
	JMS	UNPACK		/RETURN IF NO ERROR OCCURRED.
/
/ CONVERT THE FILE NAME EXTENSION TO .SIXBT AND STORE IT IN THE DELETE CPB.
/
	.DEC
	LAC	BUF+8
	LRS	6
	LAC	BUF+7
	LRS	6
	LAC	BUF+6
	LLS	12
	.OCT
	SNA
	JMP	ERR2		/SYNTAX ERROR -- NULL EXTENSION.
	SKP
/
/ USE THE DEFAULT EXTENSION "SRC".
/
USESRC	LAC	(232203)	/.SIXBT "SRC".
	DAC	DELETE+5
/
/ DELETE THE FILE AND WAITFOR COMPLETION.
/
	CAL	DELETE		/DELETE THE FILE.
	CAL	WAITFR
	LAC	EV
	SAD	(-13)
	JMP	ERR3		/FILE NOT FOUND.
	SAD	(-54)
	JMP	ERR4		/FILE STILL OPEN.
	SPA
	JMP	ERR5		/DELETE ERROR.
/
	.EJECT
/ VALIDATE THE DELIMITER.
/
	LAC	CHAR
	SAD	(54)		/COMMA?
	JMP	NEXFIL		/YES -- PROCESS THE NEXT FILE NAME.
	SAD	(175)		/ALTMODE?
	CAL	(10)		/YES -- SIMPLY EXIT.
	SAD	(15)		/CARRIAGE RETURN?
	SKP			/YES.
	JMP	ERR2		/NO -- ILLEGAL DELIMITER.
EXIT	CAL	REQTDV		/REQUEST "TDV...".
	CAL	(10)		/EXIT WITHOUT WAITING FOR RESULT.
/
/ ERRORS -- PRINT THE ERROR MESSAGE AND THEN REQUEST "TDV..." EVEN IF
/ THE LINE TERMINATOR IS AN ALTMODE.
/
ERR1	LAC	(MES1)		/COMMAND LINE TOO LONG.
	SKP
ERR2	LAC	(MES2)		/SYNTAX ERROR.
	SKP
ERR3	LAC	(MES3)		/FILE NOT FOUND.
	SKP
ERR4	LAC	(MES4)		/FILE STILL OPEN.
	SKP
ERR5	LAC	(MES5)		/"DELETE" ERROR.
	DAC	TYPE+4
	LAC	EV		/SAVE EV VALUE SO THAT SOMEONE MAY EXAMINE
	DAC	ERRCOD		/IT BY USING THE "OPEN" MCR FUNCTION.
	CAL	TYPE		/TYPE THE MESSAGE.
	CAL	WAITFR
	JMP	EXIT
/
TYPE	2700			/"WRITE" CPB.
	EV
	TDVTTY			/TDV TTY ERROR LUN.
	2			/IOPS ASCII.
	XX			/MESSAGE ADDRESS.
/
MES1	005002; 0; .ASCII "DEL-LINE TOO LONG"<15>
MES2	004002; 0; .ASCII "DEL-SYNTAX ERR"<15>
MES3	005002; 0; .ASCII "DEL-FILE NOT FOUND"<15>
MES4	005002; 0; .ASCII "DEL-FILE STILL OPEN"<15>
MES5	004002; 0; .ASCII "DEL-DELETE ERR"<15>
/
	.EJECT
/ SUBROUTINE UNPACK -- UNPACK 7-BIT ASCII CHARACTERS FROM THE COMMAND
/ INPUT LINE AND STORE THEM SEQUENTIALLY IN "BUF" VIA X10 (ALREADY SET UP).
/ THE NEGATIVE COUNT OF (MAXIMUM NUMBER OF CHARACTERS + 1) IS IN THE AC.
/
/ CALLING SEQUENCE:
/
/	-COUNT IN THE AC
/	JMS	UNPACK
/	(RETURN IF NO ERROR OCCURRED)
/
/ ALTERED REGISTERS:
/
/	AC & MQ
/
UNPACK	0
	DAC	CNT		/SAVE COUNT.
LOOP1	JMS	FAC		/FETCH A CHARACTER.
	DAC	CHAR
	SAD	(54)		/COMMA?
	JMP	NOT6BT		/YES -- DELIMITER.
	AAC	-41
	SPA
	JMP	NOT6BT		/NOT .SIXBT. CHAR < 41.
	AAC	-77
	SMA
	JMP	NOT6BT		/NOT .SIXBT. CHAR > 137.
	ISZ	CNT
	SKP
	JMP	ERR2		/TOO MANY CHARACTERS.
	LAC	CHAR		/STORE CHARACTER.
	DAC*	X10
	JMP	LOOP1
/
/ FILL IN THE REMAINDER OF THE NAME WITH ZEROS.
/
	DZM*	X10
NOT6BT	ISZ	CNT
	JMP	.-2
	JMP*	UNPACK
/
	.EJECT
/ SUBROUTINE FAC -- FETCH A CHARACTER FROM THE 5/7 ASCII LINE BUFFER 'FACLB'.
/ THE INDICIES 'FACLBX' AND 'FACCBX' MUST BE SET WHEN A NEW LINE IS READ.
/ CHARACTERS ARE NOT FETCHED BEYOND TERMINAL CHARACTERS.
/
/ CALLING SEQUENCE:
/
/	JMS	FAC
/	(UNCONDITIONAL RETURN WITH CHARACTER IN THE AC)
/
/ ALTERED REGISTERS:
/
/	AC & MQ
/
FAC	0
	LAC*	FACCBX		/FETCH THE NEXT UNPACKED CHARACTER FROM 'FACCB'.
	SMA			/WAS THE CHARACTER BUFFER (FACCB) EMPTY?
	JMP	FAC2		/NO -- TEST FOR A TERMINAL CHARACTER.
	LAC	(FACCB-1)	/YES -- REFILL 'FACCB' FROM THE INPUT LINE.
	DAC	FACCBX
	LAC*	FACLBX		/(FIRST HALF OF WORD PAIR).
	IDX	FACLBX
	LMQ
	CLA!CLL
	JMS	FACUPS		/(FIRST CHARACTER).
	JMS	FACUPS		/(SECOND CHARACTER).
	JMS	FACUPS		/(FIRST 4 BITS OF THIRD CHARACTER).
	LAC*	FACLBX		/(SECOND HALF OF WORD PAIR).
	IDX	FACLBX
	LRS	17		/(LAST 3 BITS OF THIRD CHARACTER).
	XOR*	FACCBX
	DAC*	FACCBX
	CLA
	JMS	FACUPS		/(FOURTH CHARACTER).
	JMS	FACUPS		/(FIFTH CHARACTER).
	LAC	(FACCB)		/RESET THE CHARACTER BUFFER INDEX.
	DAC	FACCBX
	LAC*	FACCBX		/FETCH THE FIRST CHARACTER FROM THE
				/CHARACTER BUFFER.
/
FAC2	SAD	(015)		/IF IT IS A TERMINAL CHARACTER, CARRIAGE
	JMP*	FAC		/RETURN OR ALTMODE, RETURN WITH THE CHARACTER
	SAD	(175)		/IN THE AC BUT DO NOT AUGMENT THE CHARACTER
	JMP*	FAC		/BUFFER INDEX. THUS, REPEATED CALLS TO FAC
				/WILL RETURN THE TERMINAL CHARACTER.
/
	IDX	FACCBX		/IT IS NOT A TERMINAL CHARACTER -- AUGMENT
	JMP*	FAC		/THE CHARACTER BUFFER INDEX AND RETURN WITH
				/THE CHARACTER IN THE AC.
/
	.EJECT
/ SUBROUTINE FACUPS -- UNPACKING SUBROUTINE USED BY 'FAC'.
/
/ CALLING SEQUENCE:
/
/	AC & LINK MUST BE CLEARED.
/	NEXT CHARACTER MUST BE IN
/	THE HIGH-ORDER END OF THE MQ.
/	'FACCBX' MUST  POINT TO THE
/	WORD PRECEDING THE ONE IN
/	WHICH THE CHARACTER IS TO
/	BE STORED.
/	JMS	FACUPS
/	(UNCONDITIONAL RETURN WITH
/	'FACCBX' POINTING TO THE
/	STORED CHARACTER AND WITH
/	THE AC & LINK LEFT CLEARED)
/
/ ALTERED REGISTERS:
/
/	AC & MQ
/
FACUPS	0
	LLS	7		/SHIFT THE CHARACTER INTO THE AC. THE LOW
	IDX	FACCBX		/ORDER BITS OF THE THIRD CHARACTER ARE ZERO
	DAC*	FACCBX		/BECAUSE THE LINK IS ZERO.
	CLA
	JMP*	FACUPS
/
FACLBX	XX			/LINE BUFFER INDEX.
FACCBX	XX			/CHARACTER BUFFER INDEX.
FACCB	.BLOCK	5		/CHARACTER BUFFER (5 IMAGE ALPHA CHARACTERS).
	-1			/END-OF-'FACCB' INDICATOR.
/
	.EJECT
REQTDV	1			/"REQUEST" CPB.
	0			/NO EVENT VARIABLE.
	.SIXBT	"TDV"
	.SIXBT	"..."
	0			/USE THE DEFAULT PRIORITY.
/
DELETE	3500			/"DELETE" CPB.
	EV
	LUN
	.SIXBT	"---"		/FILE NAME -- 1ST HALF.
	.SIXBT	"---"		/FILE NAME -- 2ND HALF.
	.SIXBT	"---"		/FILE NAME -- EXTENSION.
/
XFER	37			/"TRANSFER TDV COMMAND LINE" CPB.
	EV
	FACLB			/BUFFER ADDRESS.
	CBFSIZ			/BUFFER SIZE.
/
WAITFR	20			/"WAITFOR" CPB.
	EV
/
EV	0			/EVENT VARIABLE.
CNT	0			/COUNTER.
CHAR	0			/INPUT CHARACTER.
ERRCOD	0			/EV VALUE SAVED BEFORE ERROR PRINTOUT IN
				/CASE SOMEONE WANTS TO EXAMINE IT USING
				/THE "OPEN" MCR FUNCTION.
/
	.DEC
BUF	.BLOCK 9		/FILE NAME BUFFER.
	.OCT
/
FACLB	.BLOCK	CBFSIZ		/COMMAND INPUT BUFFER, OR
				/FETCH-A-CHARACTER BUFFER.
	064032			/GUARD WORD -- GUARANTEES FINDING
				/CARRIAGE RETURN AT END OF BUFFER.
/
	.END	DEL
