.;
.;----------------------------------------------------------------------------
.;
.;	CMD-PROGRAM:	COMPIL.CMD
.;
.;	AUTHOR:		J.H. Belgraver
.;
.;	DATE:		8-SEP-80
.;
.;	PURPOSE:	Modified from COPY.CMD PIP copy command file.
.;
.;	MODIFIED BY:	Jan H. Belgraver	17-MAR-82	JB01
.;
.;	MODIFIED BY:	Jan H. Belgraver	31-JAN-83	JB02	V1.2
.;			For compatibility with DCL.
.;
.;----------------------------------------------------------------------------
.;
.ENABLE SUBSTITUTION
.ENABLE	QUIET								! JB02
	.SETF	DCL							! JB02
	.IF	<CLI> EQ "DCL"	.SETT	DCL				! JB02
.;	If current CLI is DCL reset to MCR				! JB02
	.IFT	DCL	SET TERMINAL/MCR
.DISABLE	QUIET							! JB02
.;
.;
.SETS	SPOOL	"/-SP"
.SETF	OBJ
.SETF	LST
.SETF	SPL
.SETF	FLAG
.SETF	GO
.SETS	STRING ""
.;
.;	ASK FOR COMMAND PARAMETERS IF NOT PRESENT
.;
		.ASK	OBJ	OBJ-files      [<CR>=N]	.
		.ASK	LST	LST-files      [<CR>=N]	.
.IFT	LST	.ASK	SPL	Spooling lists [<CR>=N]	.
.IFT	SPL	.SETS	SPOOL	"/SP"
.;
.;	FIND OUT WHAT TO COMPILE
.;
	PIP DIRECTORY.TMP;1234='P1'*.FTN/BR
.WAIT	PIP
.OPENR	DIRECTORY.TMP;1234
.LOOP:
	.SETS	PREVIO	STRING
.;
	.READ	RECORD
	.IFT	<EOF>	.GOTO EXIT
	.IF	<FILERR> NE 1	.GOTO ERROR
	.TEST	RECORD
.;
.;	GET RID OF <CR><LF>
.;
	.IF	<STRLEN> LE 2	.GOTO LOOP
	.SETS	STRING	RECORD[3:<STRLEN>]
	.PARSE	STRING	".;"	NAME TYPE VERS
	.IF	TYPE EQ ""	.GOTO LOOP
.;
.;	WATCH OUT FOR THE FILE ITSELF
.;
	.IF	NAME NE "DIRECTORY"	.GOTO MORE
	.IF	TYPE NE "TMP"		.GOTO MORE
	.IF	VERS NE "1234"		.GOTO MORE
	.GOTO	LOOP
.MORE:
	.IFT	GO	.GOTO FOR
	.ASKS	ANSWER	Compile 'STRING' [Y,N,Q,G,^] ?
	.IF	ANSWER EQ ""	.GOTO LOOP
	.SETS	FIRST		ANSWER [1:1]
	.IF	FIRST EQ "N"	.GOTO LOOP
	.IF	FIRST EQ "Y"	.GOTO FOR
	.IF	FIRST EQ "Q"	.GOTO EXIT
	.IF	FIRST EQ "G"	.SETT GO
	.IF	FIRST EQ "^"	.SETT FLAG
.;
	.IFT	GO	.GOTO FOR
	.IFF	FLAG	.GOTO MORE
	.SETS	CURREN	STRING
	.SETS	STRING	PREVIO
.FOR:
.;
	.PARSE	STRING	".;"	NAME TYPE VERS
.;
	.SETS	OBJF	""
	.SETS	LSTF	""
	.IFT	OBJ	.SETS	OBJF	NAME
	.IFT	LST	.SETS	LSTF	NAME
	F4P	'OBJF','LSTF''SPOOL'='NAME'
	.WAIT	F4P
	.IFF	FLAG .GOTO LOOP
	.SETF	FLAG
	.SETS	STRING CURREN
	.GOTO	MORE
.ERROR:
	.DISABLE QUIET
	;..... ERROR '<FILERR>' IN '<FILSPC>'
.EXIT:
	PIP DIRECTORY.TMP;1234/DE
.FINISH:
	.ENABLE	QUIET							! JB02
	.;	If user CLI was DCL reset terminal.			! JB02
	.IFT	DCL	SET /DCL=TI:
.EXIT
