	.ENABLE SUBSTITUTION
	.ENABLE GLOBAL
	.ENABLE ESCAPE
	.DISABLE DISPLAY
	.SETS TIMOUT "5S"
	.SETS DEFFIL ""
	.SETS DEFTYP "RNO"
	.ENABLE QUIET
	.DELAY 2S
	.DISABLE QUIET
	.SETF GOBACK
	;[1;1H[2J
	.GOSUB CHKMAL
.START:
	.DISABLE QUIET
	.SETF GOBACK
	;[1;1H[2J
.ENABLE LOWERCASE
.IF DEFFIL EQ "" .SETS STRING "Default file [7;1mNOT[0m yet set"
.IF DEFFIL <> "" .SETS STRING "Your default file is  [1m"+DEFFIL+"[0m"
.DISABLE LOWERCASE
	;
	; F U S I O N   D O C U M E N T   P R E P A R A T I O N
	;
	;		'STRING'
	;		Your default file type is [1m'DEFTYP'[0m
	;   You may
	;	 	CREATE 	   a new file
	;		DEFAULT    Change default file type
	;		DELETE 	   files
	;		DIRECTORY  See directory of files
	;		EQUATION   Create an equation file
	;		EDIT	   an existing file
	;		HELP	   Ask the system for HELP
	;		LIST 	   a file to your terminal
	;		MAIL	   Use the computer mail system.
	;		MEMO	   Create and file a MEMO.
	;		PURGE 	   files
	;		RUNOFF 	   the file to the printer
	;		SPELL	   Check a file for spelling errors
	;
	;    Enter a command or hit the RETURN key to exit and logoff
	;    (Type ^Z (ctrl-Z) to exit from this menu on any input.)
	;
	.ENABLE QUIET
.10:	.ASKS OPTN Which option do you wish to do: 
	.IF OPTN EQ "" .GOTO XIT
	.SETS TMP OPTN[1:2]
	.SETS XMP OPTN[1:3]
	.SETS INFILE ""
	.ENABLE QUIET
	.IF TMP EQ "CR"  .GOTO CREATE
	.IF XMP EQ "DEF" .GOTO DEFALT
	.IF XMP EQ "DEL" .GOTO DELETE
	.IF TMP EQ "DI"  .GOTO DIRECT
	.IF TMP EQ "ED"  .GOTO EDIT
	.IF TMP EQ "EQ"  .GOTO EQNCRE
	.IF TMP EQ "HE"	 .GOTO HELP
	.IF TMP EQ "LI"  .GOTO LIST
	.IF TMP EQ "MA"	 .GOTO MAIL
	.IF TMP EQ "ME"  .GOTO MEMO
	.IF TMP EQ "PU"  .GOTO PURGE
	.IF TMP EQ "RU"  .GOTO RUNOFF
	.IF TMP EQ "SP"  .GOTO SPELL
	.DISABLE QUIET
	;
	; Please re-enter an allowed option
	.ENABLE QUIET
	.GOTO 10
.CREATE:
	.SETS INFILE "/CR"
.EDIT:
	.GOSUB GETFIL
	.IFT GOBACK .GOTO START
	.IF DEFFIL EQ "" .IF <STRLEN> EQ 0 .GOTO START
	.ENABLE QUIET
	KED 'FILE'.'DEFTYP''INFILE'
	.GOTO START

.EQNCRE:
	.SETS TMPFIL DEFFIL
	.SETS DEFFIL ""
	.SETS INFILE "/CR"
	.GOSUB GETFIL
	.IFT GOBACK .GOTO EQNEND
	.IF DEFFIL EQ "" .IF <STRLEN> EQ 0 .GOTO EQNEND
	.ENABLE QUIET
	KED 'FILE'.RNO=EQNTMPLT.RNO
.EQNEND:.SETS DEFFIL TMPFIL
	.GOTO START

.DEFALT:
	.PARSE OPTN " " OPTN1 OPTN2
	.IF OPTN2 EQ "" .GOTO DEFLT1
	.TEST OPTN2
	.IFF <ALPHAN> .GOTO DEFLT2
	.SETS DEFTYP OPTN2[1:3]
	.GOTO START
.DEFLT1:
	.DISABLE QUIET
	;
	;Your default file type is now .'DEFTYP'
	;
	.ENABLE QUIET
	.ASKS [1:3:"'DEFTYP'"] TYP New default file type (<CR>->'DEFTYP'): 
	.TEST DEFTYP
	.IFT <ALPHAN> .GOTO DEFLT4
.DEFLT2:.DISABLE QUIET
	;
	;Invalid File Type, 1-3 Alpha characters only (ie ,RNO, TXT, Etc.)
	.GOTO DEFLT1
.DEFLT4:.SETS DEFTYP TYP
	.GOTO START

.DIRECT:
	.ENABLE QUIET
	PIP /LI
	.GOSUB HOLDIT
	.GOTO START
.RUNOFF:
	.IF <TITYPE> EQ 15 .SETS UNDRLN "/UL:S"
	.GOSUB GETFIL
	.SETS PAGRNG ""
	.GOSUB SETUP
	.IFT GOBACK .GOTO START
	.ENABLE QUIET
	.IF TYPE NE "LQ" RNO 'RNOOUT''UNDRLN'='FILE''PAGRNG'
	.IF TYPE EQ "LQ" RNO 'RNOOUT''UNDRLN'='FILE''PAGRNG'
	.IF TYPE EQ "LQ" LQ LP.LST
	.GOSUB HOLDIT
	.GOTO START

.SETUP:
	.DISABLE QUIET
	;
	;   RUNOFF output can be displayed either at your terminal, sent to
	;letter quality printer, or sent to the line printer.  Press RETURN 
	;to display output on your terminal.
	;
	.ENABLE QUIET
	.SETF LETQLT
	.SETS TYPE ""
	.SETT DSPLY
	.ASKS TYPE Output to a line or letter quality printer [ LP or LQ ]: 
	.IF TYPE NE "LP" .AND .IF TYPE NE "LQ" .SETF DSPLY
	.SETS RNOOUT "TI:"
	.IFT DSPLY .IF TYPE EQ "LP" .SETS RNOOUT "LP.LST/SP"
	.IFT DSPLY .IF TYPE EQ "LQ" .SETS RNOOUT "LP.LST/-SP"
	.IFT DSPLY .SETS UNDRLN "/UL:L"
	.ASK SLCT Select a range of pages for RUNOFF (N => all pages) [Y/N]: 
	.IFF SLCT .RETURN
	.IFT SLCT .ASKN[1.:1000.:1.] LOW Starting Page # = 
	.IFT SLCT .ASKN['LOW'.:1000.:'LOW'.] HIGH Ending Page # =   
	.SETS PAGRNG "/PA:'LOW.':'HIGH'."
	.RETURN
.SPELL:
	SPELL
	.GOSUB HOLDIT
	.GOTO START


.HELP:
	.DISABLE QUIET
	;
	; You may request HELP by entering the TOPIC or the TOPIC and
	; subtopics of interest.  If you don't know what subtopics are
	; available enter a ? for the subtopic.  The format for entering
	; topic and subtopics is    Topic Subtopic1 Subtopic2.....
	; For further information type HELP to the next question.
	;
	.ENABLE QUIET
	.ASKS HLPSTR On what do you wish help: 
	HELP 'HLPSTR'
	.GOSUB HOLDIT
	.GOTO START

.LIST:
	.GOSUB GETFIL
	.IFT GOBACK .GOTO START
	.ENABLE QUIET
	LIST 'FILE'.'DEFTYP'
	.GOSUB HOLDIT
	.GOTO START
.MAIL:
	.GOSUB CHKMAL
	.ASK SEND Would you like to send Mail: 
	.IFF SEND .GOTO START
	.DISABLE QUIET
	;
	;You may either send a previously created memo, or if you have no
	;prepared document, enter the text of your message when MAIL prompts
	;for input with MAIL>.  If you have no prepared document to send
	;type RETURN to the next question.
	;
	.ENABLE QUIET
.QUEST:	.ASKS DOCUMT Document to send (<CR>->MAIL will prompt): 
	.ASKS TOWHO Send MAIL to whom: 
	.IF <STRLEN> GT 0 .GOTO DOIT
	.DISABLE QUIET
	;
	;GYou must have a person to send mail to. If you wish to give up
	;trying to send mail, type <CR> or NO to the next quiestion.
	;
	.ENABLE QUIET
	.ASK AGAIN Try again [Y/N]: 
	.IFF AGAIN .GOTO START
	.GOTO QUEST
	;
.DOIT:	.DISABLE QUIET
	.IF DOCUMT EQ "" ;Type ^Z to exit MAIL when you are done entering text
	.ENABLE QUIET
	MAIL 'DOCUMT' TO 'TOWHO'
	.GOSUB HOLDIT
	.GOTO START



.CHKMAL:
	.SETF ISMAIL
	.PARSE <UIC> "[,]" A GRPY MEMY B
	.SETN GRP 'GRPY'
	.SETS GROUP "'GRP%Z'"
	.SETS GRP2 GROUP[4:6]
	.SETN MEM 'MEMY'
	.SETS MEMBR "'MEM%Z'"
	.SETS MEM2 MEMBR[4:6]
	.TESTFILE LB1:[10,3]'GRP2''MEM2'.TXT
	.IF <FILERR> EQ 1 .SETT ISMAIL
	.IFF ISMAIL .RETURN
	.DISABLE QUIET
	;
	;MAIL is waiting in your mailbox waiting to be read
	.ENABLE QUIET
	MAIL ?
	;
	.ASK READIT Would you like to read your mail: 
	.IFT READIT MAIL ME
	.IFT READIT .GOSUB HOLDIT
	.RETURN

.MEMO:	@MEMO
	.SETS DEFFIL $DEFIL
	.GOTO START

.PURGE:
	.SETS TMP DEFFIL
	.TESTFILE KEDXXX.TMP
	.IF <FILERR> EQ 1   .GOTO WARN
	.IF <FILERR> EQ 332 .GOTO WARN
	.GOSUB GETFIL
	.SETS DEFFIL TMP
	.IFT GOBACK .GOTO START
	.ENABLE QUIET
	PIP 'FILE'.'DEFTYP'/PU:3
	.GOTO START
.DELETE:
	.SETS TMP DEFFIL
	.GOSUB GETFIL
	.SETS DEFFIL TMP
	.IFT GOBACK .GOTO START
	.ENABLE QUIET
	SRD 'FILE'.'DEFTYP';*/LI
	.ASKS VSN Enter file version # (1-7777 or * for all versions): 
	.TEST VSN
	.IF <STRLEN> EQ 0 .GOTO DELETE
	PIP 'FILE'.'DEFTYP';'VSN'/SD
	.IF <EXSTAT> NE 1 .GOSUB HOLDIT
	.GOTO START
.GETFIL:
	.TESTFILE KEDXXX.TMP
	.IF <FILERR> EQ 1   .GOTO WARN
	.IF <FILERR> EQ 332 .GOTO WARN
	.DISABLE QUIET
	; Type ESC <CR>  (Escape-carriage return) to return to menu
	.ENABLE QUIET
	.IF DEFFIL <> "" .ASKS FILE Enter file name (<CR> => 'DEFFIL'): 
	.IF DEFFIL EQ "" .ASKS FILE Enter file name: 
	.IFT <ESCAPE> .SETT GOBACK
	.IFT GOBACK .RETURN
	.TEST FILE
	.DISABLE QUIET
	.IF DEFFIL EQ "" .IF <STRLEN> EQ 0 .SETT GOBACK
	.IFT GOBACK .RETURN
	.IF <STRLEN> EQ 0 .SETS FILE DEFFIL
	.IF <STRLEN> LE 9. .GOTO 100
	; File names must be <9. ASCII characters
	.GOTO GETFIL
.100:	.IFT <ALPHAN> .GOTO 200
	; Re-Enter a 1-9 letter name, no periods please
	.GOTO GETFILE
.200:	
	.SETS DEFFIL FILE
	.SETS TMPFIL FILE+".'DEFTYP'"
	.IF INFILE EQ "/CR" .RETURN
	.TESTFILE 'TMPFIL'
	.IF <FILERR> EQ 1 .RETURN
	.DISABLE QUIET
	;
	;'FILE'.'DEFTYP' does not exist, Try again please
	;
	.ENABLE QUIET
	.GOTO GETFIL
.WARN:
	.DISABLE QUIET
	;
	;    A temporary file exists on your directory which suggests you
	;were editing when the system crashed.  If you continue now there
	;is a good chance that previous work could be lost.  Please request
	;help from an experienced PDP-11/45 programer to insure that you
	;do not have any 0-length files.  If a 0-length file is the highest
	;numbered file you have, and a PURGE is done, all the good files
	;will be lost. GET HELP.
	;
	.GOSUB HOLDIT
	.GOTO START


.HOLDIT:
	.DISABLE QUIET
	;
	.ENABLE QUIET
	.ASKS RDY Hit RETURN on the keyboard to continue: 
	.RETURN

.XIT:  
	.ENABLE QUIET
	.ASK PRG Have you purged old copies of your files [Y/N]: 
	.IFT PRG .GOTO XIT1
	.DISABLE QUIET
	;Please use the PURGE command to remove old files prior logging off
	.ENABLE QUIET
	.DELAY 3S
	.GOTO START
.XIT1:	.ASK DONE Do you wish to logout now [Y/N]: 
	.IFF DONE .GOTO START
	.XQTC BYE
