;	ICPSLP.CMD
;
.ENABLE QUIET
.ENABLE SUBSTITUTION
.SETT SKIP1
.SETT SKIP2
.SETT SKIP3
.SETT SKIP4
.SETT SKIP5
.SETT SKIP6
.SETT SKIP7
.SETF SKIP8
.SETF SKIP9
.SETF SKIP10
.SETF SKIP11
.SETF SKIP12
.SETF SKIP13
.SETF SKIP14
.SETT ALLDON
	.IFDF $OU .GOTO DEF1
	ASN SY:=OU:
	.GOTO DEF2
.DEF1:  ASN '$OU'=OU:
.DEF2:	.IFDF $IN .GOTO DEF3
	ASN SY:=IN:
	.GOTO DEF4
.DEF3:	ASN '$IN'=IN:
.DEF4:	
.DISABLE QUIET
;
; This file will attempt to lead you through the ICP modifications.
; The ICP modifications give the user access to an <ERRSEQ> special symbol
; and access to the /-LI switch as well as changing the defaults to
; 	.ENABLE GLOBAL and .ENABLE SUBSTITUTION.
; Most users probably do not need to  attempt to modify ICP.
; It is assumed that the  user is sitting with  his/her KMSKIT on SY:.  
;
; These SLP files can optionally be applied to distribution sources
;
;       1.  [012,010]ICPPRE.MAC;1
;       2.  [012,010]ICPFIL.MAC;1
;       3.  [012,010]ICPROT.MAC;1
;       4.  [012,010]ICPSYT.MAC;1
; 
; In addition, the files ICPFDC, ICPIMP, and ICPIN2 must be reassembled with
; the modified prefix file in order for the new defaults for GLOBAL and
; substitution to take effect.
;
;	Please note.  This command file has not yet been debuged or tested.
;	I am writing it in a rush for DECUS.  I think it is OK, but...
;	Please be patient if problems occur.
;
.ASK OPTPAT Apply the optional ICP (Indirect file processor) enhancements
.IFF OPTPAT .EXIT
.ENABLE QUIET
.; Since the assembly will fail unless RSXMC.MAC exists, we are going to
.; see if it exists.  We specifically do not use the one on [11,10] since
.; it can be left incomplete by a Prep-Gen.  It is assumed that the user
.; started out with KMSGEN which tries to transfer RSXMC.MAC from the user's
.; current SYSUIC to [200,200].
.TESTFILE LB:[200,200]RSXMC.MAC
.IF <FILERR> EQ 1  .GOTO OK
.DISABLE QUIET
;
; A valid RSXMC.MAC is absolutely required to exist on LB:[200,200] prior
; to this command file being executed.  Please copy the RSXMC.MAC which
; pertains to the current target system being generated to LB:[200,200]
; and start up KMSGEN again when ready.  Exiting.....
.enable quiet
/
.OK:
.SETS OURUIC <UIC>
.ASKUIC:
.ASKS FILUIC On what UIC are SLP patch files (<cr> defaults to [344,40])
.IF FILUIC EQ "" .SETS FILUIC "[344,40]"
SET /UIC ='FILUIC'
.IF <EXSTAT> NE 1 ;You typed in an illegal UIC string try again
.IF <EXSTAT> NE 1 .GOTO ASKUIC
;
.ENABLE QUIET
SET /PRIV=TI:
.DISABLE QUIET
.IF <EXSTAT> NE 1 ; Sorry this uic is not privleged, EXITING
.IF <EXSTAT> NE 1 /

.ENABLE QUIET
.SETS DSK <SYDISK>+"'<SYUNIT>'"+":"
.Q2:.ASKS TEMP Which device is the MCR Source Disk( <CR>-EXIT, DDU)
.IF TEMP EQ "" /
.SETS $EXC TEMP[1:3]
ASN '$EXC':=SY:
.IF <EXSTAT> EQ 1 .GOTO Q3
.DISABLE QUIET
;
; You entered an illegal device or device string, Try again
;
.ENABLE QUIET
.GOTO Q2
.Q3:
.SETS UIC <UIC>
SET /UIC=[12,40]
ASN '$EXC':=SY:
PIP SY:/NV='DSK''UIC'ICPPRE.SLP,ICPFIL,ICPROT,ICPSYT
SET /UIC=[12,10]

; Test for MCR files to SLP
.SETS OLDEXT "MAC"				! TEST FOR .MAC SOURCES
.SETS NEWEXT "VGN"				! RENAME TO .VGN SOURCE
.SETS TSTUIC "[12,10]

.; 1) ICPPRE.MAC					!
.SETS FILE "ICPPRE"				! SET FILE TO RENAME
.GOSUB RENAME					! RENAME IT
.SET'SKIPIT' SKIP1				! SET SKIP FLAG

.; 2) ICPFIL.MAC
.SETS FILE "ICPFIL"				! SET FILE TO RENAME
.GOSUB RENAME					! RENAME IT
.SET'SKIPIT' SKIP2				! SET SKIP FLAG AS APPROPRIATE

.; 3) ICPROT.MAC
.SETS FILE "ICPROT"				! SET FILE TO RENAME
.GOSUB RENAME					! RENAME IT
.SET'SKIPIT' SKIP3				! SET SKIP FLAG 

.; 4) ICPSYT.MAC
.SETS FILE "ICPSYT"				! Set file to rename
.GOSUB RENAME					! Rename it if present
.SET'SKIPIT' SKIP4				! Set skip flag


.IFNINS SLP INS $SLP
SET /UIC=[12,10]
.IFF SKIP1  SLP @[12,40]ICPPRE.SLP
.IFF SKIP2  SLP @[12,40]ICPFIL.SLP
.IFF SKIP3  SLP @[12,40]ICPROT.SLP
.IFF SKIP4  SLP @[12,40]ICPSYT.SLP

.; Now see if we can place the new files in ICP11M.OLB
.;
.;
SET /UIC = [1,24]
.TESTFILE SY:[1,24]ICP11M.OLB
.IF <FILERR> EQ 1 .GOTO OK1
.DISABLE QUIET
;
; ICP11M.OLB does not exist on your current SY: (ie disk with MCR sources).
; In view of this it is going to be imposible to complete this procedure.
; Please place the distribution ICP11M.olb on this disk, and try again
;
.ENABLE QUIET
.EXIT
.OK1:
.; See if we have done this procedure once
.TESTFILE SY:[1,24]ICP11M.VLB
.IF <FILERR> EQ 1 .GOTO OK2
PIP ICP11M.VLB=ICP11M.OLB
PIP ICP11M.OLB;2/RE=ICP11M.OLB
.DISABLE QUIET
;
;ICPSLP -- The origional ICP11M.OLB is backed up to ICP11M.VLB
;
.OK2:.DISABLE QUIET
MAC ICPFIL.OBJ;1=LB:[1,1]EXEMC/ML,[200,200]RSXMC,'$EXC':[12,10]ICPPRE,ICPFIL
.IF <EXSTAT> NE 1 .SETT SKIP2
MAC ICPROT.OBJ;1=LB:[1,1]EXEMC/ML,[200,200]RSXMC,'$EXC':[12,10]ICPPRE,ICPROT
.IF <EXSTAT> NE 1 .SETT SKIP3
MAC ICPSYT.OBJ;1=LB:[1,1]EXEMC/ML,[200,200]RSXMC,'$EXC':[12,10]ICPPRE,ICPSYT
.IF <EXSTAT> NE 1 .SETT SKIP4
MAC ICPFDC.OBJ;1=LB:[1,1]EXEMC/ML,[200,200]RSXMC,'$EXC':[12,10]ICPPRE,ICPFDC
.IF <EXSTAT> NE 1 .SETT SKIP5
MAC ICPIMP.OBJ;1=LB:[1,1]EXEMC/ML,[200,200]RSXMC,'$EXC':[12,10]ICPPRE,ICPIMP
.IF <EXSTAT> NE 1 .SETT SKIP6
MAC ICPIN2.OBJ;1=LB:[1,1]EXEMC/ML,[200,200]RSXMC,'$EXC':[12,10]ICPPRE,ICPIN2
.IF <EXSTAT> NE 1 .SETT SKIP7
.SETF SKIP8				! Assume library update works
LBR ICP11M.OLB/RP/-EP=ICPFIL.OBJ;1,ICPROT.OBJ;1,ICPSYT.OBJ;1,ICPFDC.OBJ;1
.IF <EXSTAT> NE 1 .SETT SKIP8
LBR ICP11M.OLB/RP/-EP=ICPIMP.OBJ;1,ICPIN2.OBJ;1
.IF <EXSTAT> NE 1 .SETT SKIP8
PIP ICPFIL.OBJ;1/DE/NM,ICPROT.OBJ;1,ICPSYT.OBJ;1,ICPFDC.OBJ;1,ICPIMP.OBJ;1
PIP ICPIN2.OBJ;1/DE/NM

.DISABLE QUIET
.IFF SKIP1  ;ICPSLP -- ICPPRE updated
.IFF SKIP2  ;ICPSLP -- ICPFIL updated and reassembled
.IFF SKIP3  ;ICPSLP -- ICPROT updated and reassembled
.IFF SKIP4  ;ICPSLP -- ICPSYT updated and reassembled
.IFF SKIP5  ;ICPSLP -- ICPFDC reassembled
.IFF SKIP6  ;ICPSLP -- ICPIMP reassembled
.IFF SKIP7  ;ICPSLP -- ICPIN2 reassembled
.IFF SKIP8  ;ICPSLP -- A new ICP11M.OLB is ready for SYSGEN
.IFT SKIP8  ;ICPSLP -- ICP11M.OLB is incomplete, something failed.
.IFT SKIP8  ;          Delete the current version, fix problem and redo.
.ENABLE QUIET

.IFT SKIP1  .OR .IFT SKIP1  .OR .IFT SKIP3  .OR .IFT SKIP4  .SETF ALLDON
.IFT SKIP5  .OR .IFT SKIP6  .OR .IFT SKIP7  .OR .IFT SKIP8  .SETF ALLDON
.;
.IFF ALLDON .GOTO BADBAD
.DISABLE QUIET
;
; This ends the ICP SLP modifications. You can use the SYSGEN taskbuild
; command files to rebuild ICP.  Remember, if you want to create a default
; command procedure [UIC]= [1,5] on LB: you must edit ICPBLD.BLD and 
; ICPBLD.CMD and find the line
;
;			.DATA GBLDEF=D$CUIC:1
; and change it to
;			.DATA GBLDEF=D$CUIC:405  ; Octal for UIC=[1,5]
;
;
SET /UIC ='OURUIC'
ASN 'DSK'=SY:
.EXIT
.BADBAD:.DISABLE QUIET
	;
	;  One or more of your ICP modules has not been updated or the
	;  creation of a new ICP11M.OLB failed.
	;  Find out why and fix the problem.
	;
	.ENABLE QUIET
SET /UIC ='OURUIC'
ASN 'DSK'=SY:
.EXIT 4

.; Subroutine to test/rename files prior to SLPing
.; FILE = name of file to be SLPed
.; OLDEXT = old file name extension
.; NEWEXT= new file name extension
.; SKIPIT=<TRUE>  if FILE.NEWEXT exists
.;       =<FALSE> if FILE.NEWEXT does not exist and can't be renamed 
.RENAME:
.SETT SKIPIT				!
.TESTFILE 'TSTUIC''FILE'.'OLDEXT';1
.IF <FILERR> EQ 1 .SETF SKIPIT		! If EQ yes,it exists, don't skip SLP
.IFF SKIPIT .GOTO RENAM1		! IFF, it exists, go rename it
.; If it doesn't, maybe already renamed
.TESTFILE 'TSTUIC''FILE'.'NEWEXT';1
.IF <FILERR> EQ 1 .SETF SKIPIT		! If EQ, it has been renamed
.IFF SKIPIT .RETURN			! IFF, has been renamed, skip rename
.; 
.; At this point the file neither exists, nor has it already been renamed
.DISABLE QUIET
;
; 'FILE'.'OLDEXT';1 is not on this device/uic.
; >>>>WARNING, This patch failed!
;
.ENABLE QUIET
.RETURN
.RENAM1:
PIP 'FILE'.'NEWEXT'/RE='FILE'.'OLDEXT';1	! RENAME THE FILE
.IF <EXSTAT> NE 1 .SETT SKIPIT		! IF RENAME FAILS
.DISABLE QUIET
;
.IFT SKIPIT ; Error renaming 'FILE'.'OLDEXT' to 'FILE'.'NEWEXT'
.IFF SKIPIT ; File 'FILE'.'OLDEXT' renamed to 'FILE'.'NEWEXT'
;
.ENABLE QUIET
.RETURN					! RETURN TO MAINLINE
