.; INDCLI - COMMAND LINE PROCESSOR FOR INDIRECT MCR
.; LAST EDIT:	28-SEP-81
.;
.; THIS MACRO PROVIDES A GENERALISED INDIRECT FILE FACILITY FOR INDIRECT
.; MCR. IT PROVIDES ONE LEVEL OF COMMAND FILES USING UNIT #3.
.; @TI: MAY BE USED TO CREATE IMMEDIATE MODE COMMAND FILES.
.;
.; ON ENTRY THE FOLLOWING GLOBAL VARIABLES CONTROL FUNCTION:
.;	$PRMPT	- PROMPT STRING TO BE USED FOR COMMAND LINE REQUESTS
.;	$CMD0	- IF THIS PARAMETER IS DEFINED AND NON-NULL ON INPUT
.;		  IT IS USED AS THE COMMAND LINE DIRECTLY, OTHERWISE
.;		  A QUESTION IS POSED USING $PRMPT.
.;
.;	$CMD	- ON RETURN FROM THE MACRO THIS VARIABLE CONTAINS THE
.;		  NEXT COMMAND LINE TO BE PROCESSED, OR NULL IF THERE
.;		  ARE NO MORE LINES. IF $CMD IS NOT NULL IT WILL CONTAIN
.;		  EITHER THE SINGLE STRING VALUE OF $CMD0 OR THE VALUE
.;		  REPLIED BY THE USER OR THE NEXT LINE FROM AN INPUT
.;		  FILE SPECIFIED BY $CMD0 OR THE USER.
.;		  $CMD IS NULL ON RETURN AND <STRLEN>=0 IF THE USER
.;		  TYPES CR OR END OF A COMMAND FILE IS REACHED.
.;
.;	$REPT	- IS USED AS AN INTERNAL VARIABLE AND SHOULD NOT BE MODIFIED
.;		  BY THE CALLER.
.;
.;	AFTER PROCESSING A COMMAND LINE OBTAINED FROM THIS MACRO THE
.;	CALLER SHOULD LOOP BACK TO OBTAIN THE NEXT LINE FROM THE COMMAND
.;	FILE IF ANY. EX.
.;
.;		.ENABLE GLOBAL
.;		.SETS $PRMPT "NAME OF TASK TO BUILD"
.;	.100:	@INDCLI
.;		.IF <STRLEN> EQ 0 .EXIT
.;		.
.;		.
.;		.GOTO 100
.;
.;
.;
	.ENABLE SUBSTITUTION
	.ENABLE GLOBAL
	.ENABLE QUIET
.;
.INDCLI:.IFNDF	$REPT	.SETN $REPT 0
	.IFNDF $CMD0 .GOTO 100
	.IF $CMD0 EQ "" .GOTO 100
	.IF $REPT EQ 0	.SETN $REPT 1
	.IF $CMD0 EQ "%OPEN%" .GOTO 300
	.GOTO 150
.100:	.IF $REPT EQ 1	.GOTO 2000
	.SETN $REPT 2
	.IFNDF $PRMPT .SETS $PRMPT "IND>"
	.ASKS $CMD0 '$PRMPT'
.150:	.IF $CMD0 EQ "" .GOTO 2000
	.SETS CH $CMD0[1:1]
	.IF CH EQ "@" .GOTO 200
	.SETS	$CMD	$CMD0
	.SETS	$CMD0	""
	.GOTO	1000
.;
.200:	.IF $CMD0 EQ "@TI:" .GOSUB RDTTY
	.TEST $CMD0
	.SETS FILE $CMD0[2:<STRLEN>]+".CMD"
	.TESTFILE 'FILE'
	.IF <FILERR> EQ 1 .GOTO 210
	.DISABLE QUIET
;
; OPEN ERROR '<FILERR>' FILE: 'FILE'
;
	.GOTO 2000
.;
.210:	.OPENR #3 'FILE'
	.SETS	$CMD0	"%OPEN%"
.;
.300:	.READ #3 $CMD
	.IFF <EOF> .GOTO 1000
	.CLOSE #3
	.GOTO 1500
.1000:	.SETS CH $CMD[1:1]
	.IF CH EQ ";" .GOTO INDCLI
	.TEST $CMD
	.EXIT
.;
.1500:	.IF $REPT EQ 2	.GOTO 100
.2000:	.SETS $CMD ""
	.SETS $CMD0 ""
	.SETN $REPT 0
	.GOTO 1000
.;
.; THIS SUBROUTINE IS CALLED WHEN THE INDIRECT FILE IS THE TERMINAL
.;
.RDTTY:	PIP TITEMP.CMD;*/DE/NM
	.SETN N 1
	.OPEN #3 TITEMP.CMD
	; ENTER COMMANDS, CR TERMINATES
.RD:	.ASKS STR 'N'
	.IF <STRLEN> EQ 0 .GOTO RDEND
	.DATA #3 'STR'
	.INC N
	.GOTO RD
.;
.RDEND:	.CLOSE #3
	.SETS $CMD0 "@TITEMP"
	.RETURN
