.ENABLE SUBSTITUTION
.ENABLE CONTROL-Z
.ENABLE GLOBAL
.DISABLE QUIET
.DISABLE DISPLAY
.SETF DEFALT
.SETF CREATE
.SETS SPACES "                                                            "
.SETS TYPE "MEM"
.SETS $DEFIL ""
.SETF SKIP
.;
.;                    Memo Generator and Filing
.;
;[1;1H[2J
;
.;
;                     Memo Creation and Filing
;		   (Type ^Z to exit at any point)
;
	.SETS ANSFIL TYPE+"DEFALT.CMD"
	.TESTFILE 'ANSFIL'
	.IF <FILERR> EQ 1 .GOTO INDFIL
	;
	; Your default answers do not yet exist.  Lets enter them
	; now so that they can be used in the future.
	;
	.GOSUB GETANS
	.GOTO SKIP
.INDFIL:@'ANSFIL'
.SKIP:
	.SETN $MEMO 0
	.TESTFILE LAST'TYPE'.CMD;1
	.IF <FILERR> NE 1 .GOTO NONMBR
	@LAST'TYPE'.CMD;1
	;
	;The last memo # entered is '$MEMO'
	;
	.INC $MEMO
.NONMBR:.ASKS [1:5:"'$MEMO'"] MEMNBR '$FNAME', What is the memo # (<CR>->'$MEMO'): 
	.IFT <EOF> .EXIT
	.SETS PPN ""
	.ASKS [1:3:"'$LOCL'"] $LOCL '$FNAME', What is the memo prefix code (<CR>->'$LOCL'): 
	.IFT <EOF> .EXIT
	.TESTFILE '$LOCL''MEMNBR'.RNO
	.IF <FILERR> NE 1 .GOTO NEWFIL
	.DISABLE QUIET
	;
	;Warning - The memo file '$LOCL''MEMNBR'.RNO already exists
	;
	.ENABLE QUIET
	.ASK ANS '$FNAME', Do you want to delete '$LOCL''MEMNBR'.RNO [Y/N]: 
	.IFT <EOF> .EXIT
	.IFT ANS PIP '$LOCL''MEMNBR'.RNO;*/DE
	.IFF ANS .GOTO REFCOD
.NEWFIL:
	.OPEN LAST'TYPE'.CMD;1
	.DATA .SETN $MEMO 'MEMNBR'.
	.CLOSE
;
.GETHDR:
	.ASKS TOWHO To whom:   
	.IFT <EOF> .EXIT
	.TEST TOWHO
	.IF <STRLEN> GT 18. .GOTO TOLONG
	.ASKS FROM From whom: 
	.IFT <EOF> .EXIT
	.TEST FROM
	.IF <STRLEN> GT 18. .GOTO TOLONG
	.ASKS [1:69.] SUBJCT Subject:   
	.IFT <EOF> .EXIT

.OPEN '$LOCL''MEMNBR'.RNO
.ENABLE DATA
.rm72
.lm5
.lit
                                                      '$LOCL'-'MEMNBR'
MEMO:
TO:       'TOWHO'
FROM:     'FROM'
SUBJECT:  'SUBJCT'
DATE:     '<DATE>'
.end literal
.ap
.DISABLE DATA
.CLOSE

	.TESTFILE 'TYPE'LST.FIL
	.IF <FILERR> EQ 1 .GOTO OLDFIL
	.OPEN 'TYPE'LST.FIL
	.DATA Memo #       Date         From                To              Subject
	.GOTO UPDATE
	.OLDFIL:.IF <FILERR> EQ 1 .OPENA 'TYPE'LST.FIL
.UPDATE:
	.TEST FROM
	.SETS SPC1 SPACES[1:20.-<STRLEN>]
	.TEST TOWHO
	.SETS SPC2 SPACES[1:20.-<STRLEN>]
	.SETS MEMO $LOCL+"-"+MEMNBR
	.TEST MEMO
	.SETS SPC00 SPACES[1:10.-<STRLEN>]
	.DATA 'MEMO''SPC00''<DATE>'   'FROM''SPC1''TOWHO''SPC2''SUBJCT'
	.CLOSE
	.ENABLE QUIET
	KED '$LOCL''MEMNBR'.RNO
	.SETS $DEFIL "'$LOCL''MEMNBR'"
	PIP '$LOCL''MEMNBR'.RNO/PU
	.EXIT

.GETANS:
	.OPEN 'TYPE'DEFALT.CMD;1
	.ASKS $FNAME What is your first name: 
	.IFT <EOF> .EXIT
	.DATA .SETS $FNAME "'$FNAME'"
	.ASKS $LNAME What is your last name: 
	.IFT <EOF> .EXIT
	.DATA .SETS $LNAME "'$LNAME'"
	.ASKS [1:3] $LOCL What should be the default prefix code for memos: 
	.IFT <EOF> .EXIT
	.DATA .SETS $LOCL "'$LOCL'"
	.CLOSE
	.RETURN

.TOLONG:
	.DISABLE QUIET
	;
	;MEMO -- Error. The FROM/TO name lengths must be < 19 characters long
	;
	.GOTO GETHDR
