.;
.;	EDT.CMD - Command file to remember the name of the file just edited
.;
.;	Author: Don Rubin	Version: 1.0	Date: January 1982
.;
	.ENABLE TIMEOUT
	.ENABLE SUBSTITUTION
	.SETS	SWIT ""
	.IF	P1 EQ "" .IF P2 EQ "" .GOTO OLD  !no command line so assume re-edit

.NEW:
	.PARSE	P1 "=" OUT IN	!see if input and output files specified
	.IF	IN NE "" .GOTO INPUT

.OUTPUT:
.;	Output file only specified
	.PARSE	P1 "./" P3 P4 SWIT !see if file extension and/or switch is given
	.IF	P4 EQ "" .SETS P1 P1+".FTN"	!add default extension
	.OPEN	#1 EDT.TMP;1
	.DATA	#1 'P1'
	.CLOSE	#1
	.SETS	FILE "'P1'"
	.GOTO	EDT		!now edit the file

.INPUT:
.;	Input and output file specfied
	.OPEN	#1 EDT.TMP;1
	.DATA	#1 'OUT'
	.CLOSE	#1
	.SETS	FILE "'OUT'='IN'"
	.GOTO	EDT		!now edit the file

.OLD:
.;	A filename already exists, first try to open our container file
	.TESTFILE EDT.TMP;1
	.IF <FILERR> NE 1 .GOTO NOTMP	!cant do it
	.OPENR	#1 EDT.TMP;1
	.READ	#1 FILE		!read in the saved filename to edit
	.CLOSE	#1

.;	Show the filename to the user, see if its the one he wants

; We will now edit 'FILE'
.ASK [:2S] Y Do you want to edit a different file
.IFF Y .GOTO EDT

.ASKS P1 Enter the name of the file you want to edit
.IF <STRLEN> LE 0 .GOTO END
.GOTO OUTPUT

.EDT:
.;	Call up our favorite editor
	.XQT EDT 'FILE''SWIT'

	.GOTO END

.NOTMP:
; Error - No saved EDT file in this directory

	.END:
.DISABLE DISPLAY
