.; From "The Multi-tasker" Dec 1983 pp 4-5
	.ENABLE SUBSTITUTION
	.SETS NULL ""
	.SETN N 1.
	.SETF MAKFIL
	.SETS CMDNAM "TMP.TMP"
	.IF P1 = "?" .OR .IF P1 = "HELP" .GOSUB HELP
	.PARSE COMMAN "<><>" DUMMY SRD DUMMY XXX TEMP
.;
.;  If no SRD selection, take one
.;
	.SETT INLINE
	.IF XXX <> "" .GOTO STRIN
	.SETF INLINE
	.IF SRD <> "" .GOTO CMDS
	.ASK MAKFIL Generate command file only (without executing it)
	.IFF MAKFIL .GOTO SWORD
	.ASKS [::"'CMDNAM'"] CMDNAM File name
.SWORD:
	.ASKS SRD SRD selection (CR or ^Z to exit)
	.IF SRD = "" .EXIT
	.ASKN [::1.] REPEAT No of times to repeat commands for each file
	.SETS TEMP "'REPEAT'"
.; If on command line, loop and read strings
.;
.CMDS:
; Command line 'N' (CR if no more)
	.ENABLE QUIET
	.ASKS XXX
	.DISABLE QUIET
	.IF XXX = "" .GOTO SORT
.STRIN:	.SETS CMD'N' XXX
	.SETN REPEAT 0'TEMP%C'.
	.IF REPEAT = 0 .SETN REPEAT 1
.;
.; Parse command line for later use
.;
	.PARSE CMD'N' "$" Q1'N' Q2 Q3 Q4 Q5 Q6 Q7 Q8
	.SETN NN 2.
.PIECE:
	.SETS Q'NN''N' "$"+Q'NN'[1:1]
	.IF Q'NN''N' = "$" .SETS Q'NN''N' "NULL"
	.SETS R'NN''N' Q'NN'[2:*]
	.INC NN
	.IF NN <= 8. .GOTO PIECE
	.INC N
	.IF N <= 5 .AND .IFF INLINE .GOTO CMDS
.;
.; Make SRD selection to temp file and open for read
.;
.SORT:	.IF N = 1 .EXIT
	SRD SP:SRD.TMP='SRD'/LI/-SU
	.IF <EXSTAT> <> 1 .GOTO FINIS
	.ONERR FINIS
	.OPENR SP:SRD.TMP
	.IFT MAKFIL .OPEN #1 'CMDNAM'
.;
.; Read SRD file and select filename.
.; Parse for $x's, as described in HELP.
.;
.MFD:
	.READ LINE
	.IFT <EOF> .GOTO FINIS
	.IF LINE = "" .GOTO MFD
	.SETS TEST LINE[1:3]
	.IF TEST <> " **" .GOTO FINIS
.NEWDIR:
	.PARSE LINE "  [,]" DUMMY DUMMY $D $G $O DUMMY
	.SETS $U "["+$G+","+$O+"]"
.;
.LOOP:	.READ LINE
	.IFT <EOF> .GOTO FINIS
	.IF LINE = "" .GOTO LOOP
	.SETS TEST LINE[14.:14.]
	.IF TEST <> ";" .GOTO MFD
	.PARSE LINE ".; " $F $T $V DUMMY
	.SETS $F "'$F%C'"
	.SETS $T ".'$T%C'"
	.SETS $V ";"+$V
	.SETS $N $D+$U+$F+$T+$V
.;
.; Execute commands and/or build command file for each line
	.SETN R REPEAT
.RPT:
	.SETN NNN 1.
.MAKE:
	.IFNDF CMD'NNN' .GOTO ENDCOM
	.SETS COMAND Q1'NNN'
	.SETN MMM 2.
.APPEND:
	.SETS TEMP "Q'MMM''NNN'"
	.SETS TEMP 'TEMP'
	.TEST TEMP
	.IFF <RAD50> .GOTO TEMPND
	.IFNDF 'TEMP' .GOTO TEMPND
	.SETS COMAND COMAND+'TEMP'+R'MMM''NNN'
	.GOTO NXTMMM
.TEMPND:
	.SETS COMAND COMAND+TEMP+R'MMM''NNN'
.NXTMMM:
	.INC MMM
	.IF MMM <= 8. .GOTO APPEND
	.IFF MAKFIL 'COMAND'
	.IFT MAKFIL .DATA #1 'COMAND'
	.INC NNN
	.GOTO MAKE
.ENDCOM:
	.DEC R
	.IF R <> 0 .GOTO RPT
	.GOTO LOOP
.FINIS:	.CLOSE
	.IFT MAKFIL .CLOSE #1
	PIP SP:SRD.TMP;0/DE/NM
	.EXIT
.HELP:	; @OPS <SRD selection> <command line> count
	;	Angle brackets < and > are part of the syntax.
	;
	; <SRD selection>	is a file select string acceptable to SRD,
	; <command line>	is a template giving the form of '<CLI>' command lines
	;			to be generated/executed for the selected files. It
	;			contains commands or substitution directives in the
	;			form $x, one of:
	;	$N	entire filename		$D	device (including :)
	;	$U	entire UIC (inc [ & ])	$G	group
	;	$O	owner			$F	filename
	;	$T	filetype, + leading .	$V	version, + leading ;
	; count		is number of times to repeat each command (default 1)
	;
	; e.g.	@OPS <*.SAL/SV/AF:'<DATE>' <S80 $F,SP:$F=LB:[1,1]MONDEF/DF,$D$U$F>
	;
	; assembles all SAL80 files created today with the monitor definitions prefix
	; file.
	;
	; Maximum number of substitutions per line is 7.
	;
	; For multiple (<=5) commands on the same file, or to create a command file
	; for later execution, invoke OPS without a command line, and answer questions.
	.SETS COMMAN ""
	.RETURN
