.;	CAGEN.CMD   CATCH-ALL TASK GENERATOR
.;	************************************
.;	Ing.Brunecky    Ver.001   March 1981
.;
.;	Command file simplifies generation & modification
.;	of seccondary MCR command dispatcher ...CA.
.;	Following global parameters allow non-querry run:
.;	$NQR = .TRUE. - use non query run if possible
.;	$ALDV= "dduu" - assembly listing device
.;	$MPDV= "dduu" - taskbuild map listing device
.;	$TKDV= "dduu" - task image output device
.;
.;	NOTE: used UFDs [12,10],[12,24],[12,34],[1,24],[1,34],[1,54]
.;	      CA sources assumed to reside under SY:[12,10]
.;
	@LB:[1,7]PRVTST  check, if TI: privileged
	.ENABLE GLOBAL
	.IFNDF $EDI .SETS $EDI "EDI" .;default editor to be used
	.ENABLE SUBSTITUTION
	.SETS UIC  <UIC>
	.SETF CRL
	.SETF EXE
	.SETS SUIC "[12,10]"
	.SETS OUIC "[12,24]"
	.SETS DUIC "[12,34]"
	.SETS LUIC "[1,24]"
	.SETS S "CATAB"
	.GOSUB EDI
	.SETS L "CA"
	.SETS S "CA"
	.SETT EXE
	.GOSUB EDI
	.SETF EXE
	.SETS S "SCP"
	.GOSUB EDI
.;
.;	Assembly finished succesfully, prepare task-build
	.IFNDF $TKDV .ASKS $TKDV Task image output device [ddu]
	.PARSE $TKDV ":" $TKDV X
	.IF $TKDV = "" .SETS $TKDV "SY0"
	.IFNDF $MPDV .ASKS $MPDV Task map listing  device [ddu]
	.PARSE $MPDV ":" $MPDV X
	.IF $MPDV = "" .SETS $MPDV "SY0"
	.SETF INS
	.IFNDF $NQR .ASK INS Install ...CA. immediatelly
	SET /UIC=[1,24]
	.OPEN CABLD.CMD
	.DATA ;	BUILD-COMMAND FILE   ...CA.  FOR  RSX11M
	.DATA ;	****************************************
	.DATA ;
	.DATA TK:[1,54]CA/PR/-FP,MP:[1,34]CA=
	.DATA [1,24]CA/LB:CA
	.DATA [12,24]CATAB
	.DATA [1,24]CA/LB
	.DATA [1,1]EXELIB/LB
	.IFT INS .DATA '<SYSUIC>'RSX11M.STB
	.IFF INS .DATA [1,54]RSX11M.STB
	.DATA /
	.DATA TASK=...CA.
	.DATA PRI=161
	.DATA STACK=30
	.DATA UNITS=1
	.DATA ASG=TI:1
	.DATA PAR=GEN
	.DATA //
	.CLOSE
	ASN '$MPDV':=MP:
	ASN '$TKDV':=TK:
	PIP MP:[1,34]CA.MAP;*/DE/NM
	PIP TK:[1,54]CA.TSK/PU/NM
	TKB @CABLD
	.IF <EXSTAT> NE 1 ; CA taskbuild error, continue manuelly !
	.IF <EXSTAT> NE 1 .GOTO EX
	ASN =TK:
	ASN =MP:
	PIP CABLD.CMD;*/DE/NM
	.IFF INS .GOTO EX
.;
.;	Following code moves CA.TSK to SYSUIC and re-installs it
.;	both in system image RSX11M.SYS and living system on fly.
	SET /UIC='<SYSUIC>'
	.IF <SYSUIC> = "[1,54]" .GOTO 15
	PIP LB:'<SYSUIC>'/RE/NV=[1,54]CA.TSK/CD
.15:	ASN LB:=SY:
	.OPEN XXXYYY.TMP
	.DATA RSX11M.SYS
	.DATA REM ...CA.
	.DATA INS LB:CA
	.CLOSE
	.IFNINS VMR INS $VMR
	.IFNINS VMR ; VMR not available - system image not updated !
	.IFNINS VMR .GOTO 18
	VMR @XXXYYY.TMP
	PIP XXXYYY.TMP;*/DE
	ASN =SY:
.18:	.SETN N 20
.20:	REM ...CA.
	.IF <EXSTAT> = 1 .GOTO 30
	.DEC N
	.IF N > 0 .GOTO 20
	.GOTO EX
.30:	INS $CA
.EX:	SET /UIC='UIC'
	.EXIT
.;
.;	Subroutine for editing and assembly
.EDI:	.IFDF $NQR .GOTO E12
.E10:	.ASK ED Edit source file 'S'.MAC	
	.IFF ED .GOTO ASM
.E12:	SET /UIC='SUIC'
	'$EDI' 'S'.MAC
	.SETT AS
.ASM:	.IFNDF AS .SETF AS
	.IFNDF L .GOTO A10
	.TESTFILE 'LUIC''L'.OLB
	.IF <FILERR> NE 1 .SETT CRL
	.IF <FILERR> = 1 .GOTO A20
.A10:	.TESTFILE'OUIC''S'.OBJ
	.IF <FILERR> NE 1 .SETT AS
.A20:	.IFT CRL .SETT AS
	.IFF AS .RETURN
	.IFNDF $ALDV .ASKS $ALDV Assembly listing device [dduu]
	.PARSE $ALDV ":" $ALDV X
	.IF $ALDV = "" .SETS $ALDV "SY0"
	SET /UIC='OUIC'
	PIP 'S'.OBJ;*/DE/NM,'$ALDV':'DUIC''S'.LST;*/DE/NM
	.IFT EXE MAC 'S','$ALDV':'DUIC''S'/-SP=[11,10]RSXMC/PA:1,[1,1]EXEMC/ML,'SUIC''S'
	.IFF EXE MAC 'S','$ALDV':'DUIC''S'/-SP='SUIC''S'
	.SETF AS
	.IF <EXSTAT> NE 1 .GOTO E10
	.IFNDF L PIP 'S'.OBJ/PU/NM
	.IFNDF L .RETURN
	SET /UIC='LUIC'
	.IFT CRL .TESTFILE 'L'.OLB
	.IFT CRL .IF <FILERR> NE 1 LBR 'L'/CR:20
	LBR 'L'/RP='OUIC''S'
	SET /UIC='OUIC'
	PIP 'S'.OBJ;*/DE/NM
	.RETURN
