C 
C 
C                   FIRST PRINTING, FEBRUARY 1974
C 
C THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
C CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
C AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
C DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
C SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
C DOCUMENT.
C 
C THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
C NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
C A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
C INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
C USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
C VIDED IN WRITING BY DIGITAL.
C 
C DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
C FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
C MENT THAT IS NOT SUPPLIED BY DIGITAL.
C 
C COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
C 
C 
C	SLIP SRC  EDIT #4  1/13/74  G. COLE
C	COPYRIGHT DIGITAL EQUIPMENT CORP. 1973
C	SLIP  --  SOURCE LANGUAGE INPUT PROCESSOR
C
C
C	SLIP IS USED TO INSERT , DELETE AND REPLACE
C	LINES IN AN ASCII FILE . EITHER SOURC PROGRAMS
C	OR DATA CAN BE PROCESSED.
C
C	SLIP USES THE *FILE SPECIFICATIONS TO SELECT INPUT AND
C	OUTPUT FILES
C
C
C	THE GENERAL FORM OF A SLIP DECK IS
C
C	$SLIP  OPTIONS
C	*FILE  INPUT:17='INPUTFILE'  OUTPUT:18='OUTPUTFILE'  $
C	HERE 17 AND 18 ARE REPRESENTITIVE LUN NUMBERS
C	SLIP WILL PROCESS TEXTFILES FROM MOSTANY DEVICES
C	IT ALWAYS PREFORMS A COMPLETE FILE TRANSFER.
C
C	IF A NON FILE STRUCTURED DEVICE IS USED THE FORM IS:
C
C	*FILE  IN:60=''  OUT:16=''  $
C
C
C	:
C	:
C	:
C	:
C	CORRECTIONS
C	:
C	:
C	:
C	$EOF
C	END OF FILE MAY BE GENERATED FROM THE TTY BY THE
C	CORRECTION LINE  
C	-$
C
C
C
C	CORRECTIONS ARE OF THE FORMS
C
C	-N  INSERT THE FOLLOWING CARDS AFTER LINE N IN THE INPUT FILE
C
C	-N,M DELETE SOURCE LINES N TO M INSERT THE FOLLOWING CARDS
C
C	-N* SAME AS -N EXCEPT INSERT THE FILE DEFINED BY THE NEXT ARD
C
C	-N,M*  SAME AS -N,M EXCEPT INSERT THE FILE DEFINED BY THE
C				NEXT CARD
C
C	SLIP CAN ALSO SEARCH FOR LINES IN A FILE
C	THIS IS DONE BY A CORRECTION OF THE FORM
C
C	-'STR'
C
C	THIS RESETS THE LINE NUMBER TO ONE FOR THE
C	LINE FOUND SO THAT ALL SUBSEQUENT EDITING COMMANDS
C	ARE RELATIVE TO THIS LINE.
C
C	THE FOLLOWING COMMANDS ARE ALSO PROCESED
C
C	-'STR',M
C
C	-'STR'*
C
C	-'STR',M*
C
C	THE STRING STR IS UP TO 5 CHAR IN LENGTH AND
C	MUST BE FOUND AS THE FIRST 1-5 CHAR ON THE LINE
C	FOR THE SEARCH TO BE SUCESSFUL.
C
C	FORMAT OF SECONDARY FILE SPECIFICATION:
C	*FILE INPUT:15='INSERTEDFILE'
C
C
	DIMENSION A(28),B(30),C(30)
	EQUIVALENCE (B(1),IB),(B(2),A(1))
	CALL GETDC
	CALL FILES
	CALL FILUNS(1,'I',LUNIN)
	CALL FILUNS(1,'O',LUNOUT)
	WRITE(16,11)
11	FORMAT(//)
	IN=0
	IOUT=0
	ILST=1
	IBKS=1
	IEN=0
	L=0
	N=0
	M=0
C
C	COMMAND LINE PROCESSING
C
	IS=0
	IP=1
	IC=1
	CALL XFC(B(1),60,IEV)
	IF(IEV.GT.0) GOTO 800
	WRITE(13,790) IEV
790	FORMAT(' ***TDV COMMAND TRANSFER ERROR ',O6,'  SLIP EXIT'//)
	CALL EXIT
800	CALL GETCR(A,IP,IC,CHR)
	IF(IP.GT.14) GOTO 830
	IF(CHR[0:6].EQ.13) GOTO 830
	IF(IS.EQ.0) GOTO 810
	IF(CHR.EQ.1H ) GOTO 800
	GOTO 801
830	WRITE(16,7)
7	FORMAT(//)
	GOTO 101
810	IF((CHR.EQ.1H ).OR.(CHR.EQ.1H,)) IS=1
	GOTO 800
820	IS=0
	GOTO 800
801	IF(CHR.NE.1HL) GOTO 802
	ILST=1
	GOTO 820
802	IF(CHR.NE.1HN) GOTO 803
	ILST=-1
	GOTO 820
803	IF(CHR.NE.1HS) GOTO 804
	IBKS=1
	GOTO 820
804	IF(CHR.NE.1HK) GOTO 805
	IBKS=0
	GOTO 820
805	IF(CHR.NE.1HC) GOTO 806
	ILST=0
	GOTO 820
806	WRITE(13,8066) CHR
8066	FORMAT(' **SLIP DOESNT HAVE AN',1X,A1,1X,'OPTION--IGNORED')
	GOTO 820
C
C
C	IN  	INPUT FILE LINE #
C	OUT	OUTPUT FILE LINE #
C	ILST 	-1=NOTHING  0=CORRECTIONS  1=OUTPUT   LISTED
C	IBKS	0=NOTHING  1=SUPRESS TRAILING BLANKS
C	IEN	1 WHEN END OF INPUT FILE REACHED
C	L	0 FOR CORRECTION CARD INPUT  1 FOR FILE INPUT
C	N	LINE NUMBER WHERE CORRECTION STARTS
C	M	LINE NUMBER WHERE CORRECTION ENDS
C
C
C	FILES:
C		17:	INPUT
C		18:	OUTPUT
C		15:	SECONDARY INPUT FILE
C		16:	LINEPRINTER OUTPUT
C		12:	CORRECTION CARD INPUT
C
C
C
C
C	SUBROUTINES:
C
C	CNTC(A,N,M,L,SEARCH WORD,LUNSEC FILE,NUM CHAR TO COMPARE)
C		READS A CORRECTION LINE AND DECODES IT
C				OPENS SECONDARY FILE IF NEEDED
C
C		COMPS(A,IBKS,LL) SUPRESSES TRAILING BLANKS IF IBKS
C				IS GT 1, RETURNS OUTPUT LENGTH IN LL
C
C
C
C
C
C
C
1011	IF(L.LT.0) L=L+2
	IF((M.GT.0).AND.(ILST.GE.0)) WRITE(16,6) (A(J),J=1,LL)
101	IF(L.EQ.-2) GOTO 970
	IF(L.NE.0) GOTO 102
C	READ IN CORECTION LINES HERE
	CALL SLI(12,B,IENF)
	IF(IENF.GT.0) GOTO 99
	XA=1H 
	XA[0:6]=A(1)[0:6]
	IF((ILST.GE.0).AND.(XA.EQ.1H-)) WRITE(16,4) (A(J),J=1,5)
4	FORMAT('  **CHANGE**  ',5A5)
	IF(XA.EQ.1H-) GOTO 200
	GOTO 103
1	FORMAT(28A5)
102	CALL SLI(LUNSEC,B,IENF)
	IF(IENF.GT.0) GOTO 96
103	CALL COMPS(A,IBKS,LL)
C	WRITE(LUNOUT,2) (A(J),J=1,LL)
	CALL SLIOUT(LUNOUT,IB,LL)
	IOUT=IOUT+1
	IF(ILST.GE.0) WRITE(16,22) IOUT,(A(J),J=1,LL)
22	FORMAT(1X,8X,I4,2X,T15,20A5/,(T15,20A5))
	GOTO 101
200	IF((M.EQ.0).OR.(M.EQ.N))  GOTO 100
C	SCANOFF INPUT FILE TO COMLETE REPLACE OPERATION
C	WHEN A NEW CORRECTION CARD IS SEEN
201	CONTINUE
	CALL SLI(LUNIN,C,IENF)
	IF(IENF.GT.0) GOTO 98
	IN=IN+1
	IF(ILST.GE.0)  WRITE(16,6) (C(J),J=2,21)
6	FORMAT('  **DELETE**  ',20A5)
	IF(IN.LT.M) GOTO 201
	GOTO 100
96	CALL CLOSE(LUNSEC,' ',' ')
	L=0
	IF((M.EQ.0).OR.(M.EQ.N))  GOTO 101
961	CALL SLI(LUNIN,C,IENF)
C	SCANNOFF INPUT FILE TO COMPLETE REPLACE WHEN EOF ON
C	SECONDARY FILE IS SEEN
	IF(IENF.GT.0) GOTO 98
	IN=IN+1
	IF(ILST.GE.0) WRITE(16,6) (C(J),J=2,21)
	IF(IN.LT.M) GOTO 961
	GOTO 101
100	CALL CNTC(A,N,M,L,SCH,LUNSEC,ISCT)
	IF(ISCT.EQ.0) GOTO 99
	IF(L.LT.0) IN=1
106	IF(IEN.GT.0) GOTO 101
	IF(IN-N) 105,101,990
105	CALL SLI(LUNIN,B,IENF)
C	WRITE(16,404) SHC,SCH,N,M,IN,L,ISCT
C404	FORMAT(' SHC,SCH,N,M,IN,L,ISCT=',A5,1X,A5,6I8)
	SHC=5H     
	GOTO (41,42,43,44,45,46),ISCT
	GOTO 46
41	SHC[0:6]=A(1)[0:6]
	GOTO 46
42	SHC[0:13]=A(1)[0:13]
	GOTO 46
43	SHC[0:20]=A(1)[0:20]
	GOTO 46
44	SHC[0:27]=A(1)[0:27]
	GOTO 46
45	SHC=A(1)
46	CONTINUE
	IF(IENF.GT.0) GOTO 98
	IF(L.GE.0) IN=IN+1
	IF((L.LT.0).AND.(SHC.EQ.SCH)) N=IN
	CALL COMPS(A,IBKS,LL)
	IF((IN.EQ.N).AND.(M.NE.0)) GOTO 1011
C	WRITE(LUNOUT,2) (A(J),J=1,LL)
	CALL SLIOUT(LUNOUT,IB,LL)
	IOUT=IOUT+1
	IF(ILST.GT.0) WRITE(16,22) IOUT,(A(J),J=1,LL)
	IF((L.LT.0).AND.(SHC.EQ.SCH)) GOTO 1011
	GOTO 106
98	IEN=1
	GOTO 106
99	IF(IEN.GT.0) GOTO 980
C	FOLLOWING IS USED TO SCANOFF REMAINING PART OF INPUT FILE
C	WHEN EOF IS SEEN ON CORRECTION STREAM.
107	CALL SLI(LUNIN,B,IENF)
	IF(IENF.GT.0) GOTO 980
	CALLCOMPS(A,IBKS,LL)
	IF(L.GE.0) IN=IN+1
	IF(IN.GT.M) GOTO 1077
	IF(ILST.GE.0) WRITE(16,6) (A(J),J=1,LL)
	GOTO 107
C	WRITE(LUNOUT,2) (A(J),J=1,LL)
1077	CALL SLIOUT(LUNOUT,IB,LL)
	IOUT=IOUT+1
	IF(ILST.GT.0) WRITE(16,22) IOUT,(A(J),J=1,LL)
	GOTO 107
970	WRITE(16,1970) SCH
1970	FORMAT(//'  ***UNABLE TO FIND LINE BEGINNING WITH ',A5,' ***'/)
	GOTO 980
990	WRITE(16,1990) IN,N,M
1990	FORMAT(' CORRECTION CARD ERROR'/T30,'CURRENT LINE=',I6,
	1 /T30,'AFFECTED LINE=',I6,'--',I6)
980	WRITE(16,1980)
1980	FORMAT(///T40,'********** S L I P   C O M P L E T E **********'
	1 /////)
2	FORMAT(1X,28A5)
	CALL CLOSE(LUNOUT,' ',' ')
	CALL EXIT
	END
