      SUBROUTINE MAIN
      LOGICAL*1 LIN(512)
      LOGICAL*1 CLOWER
      INTEGER CKGLOB, CLRBUF, DOCMD, DOGLOB, DOREAD, GETARG
      INTEGER GETLST, PROMPT
      INTEGER I, LEN, STATUS, CLEARD
      COMMON /CFILE/ SAVFIL(40)
      LOGICAL*1 SAVFIL
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CPAT/ PAT(132)
      INTEGER PAT
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      COMMON / CSTACK / LEVEL, VRBS(2), DESC(2)
      INTEGER LEVEL
      INTEGER VRBS
      INTEGER DESC
      LOGICAL*1 PSTR(11)
      DATA PSTR(1)/58/,PSTR(2)/32/,PSTR(3)/0/
      DATA PRINT / 1 /
      CALL QUERY( 45Husage:  ed [-] [-p[string]] [-n] [-v] [file]. )
      CALL INITED
      CALL SETBUF
      NUMBER = 0
      AUTOIN = 0
      PAT(1) = 0
      SAVFIL(1) = 0
      I = 1 
23000 IF (.NOT.(GETARG( I, LIN, 512) .NE. -1 ))GOTO 23002
      IF (.NOT.( LIN(1) .EQ. 45 ))GOTO 23003
      IF (.NOT.( LIN(2) .EQ. 0 ))GOTO 23005
      PRINT = 0
      GOTO 23006
23005 CONTINUE
      IF (.NOT.( CLOWER( LIN(2) ) .EQ. 110 ))GOTO 23007
      NUMBER = 1
      GOTO 23008
23007 CONTINUE
      IF (.NOT.( CLOWER( LIN(2) ) .EQ. 112 ))GOTO 23009
      LIN(13) = 0
      CALL SCOPY( LIN, 3, PSTR, 1)
      GOTO 23010
23009 CONTINUE
      IF (.NOT.(CLOWER( LIN(2) ) .EQ. 118 ))GOTO 23011
      VRBS(1) = 1
23011 CONTINUE
23010 CONTINUE
23008 CONTINUE
23006 CONTINUE
      GOTO 23004
23003 CONTINUE
      CALL STRCPY( LIN, SAVFIL)
      IF (.NOT.( DOREAD( 0, SAVFIL, 101) .EQ. -3 ))GOTO 23013
      CALL REMARK( 2H?. )
23013 CONTINUE
23004 CONTINUE
23001 I = I + 1 
      GOTO 23000
23002 CONTINUE
      CLEARD = 0
      LEVEL=1
23015 IF (.NOT.(LEVEL .GT. 0))GOTO 23017
23018 CONTINUE
      STATUS = PROMPT( PSTR, LIN, DESC(LEVEL))
      IF (.NOT.(STATUS .EQ. -1))GOTO 23021
      GOTO 23020
23021 CONTINUE
      IF (.NOT.( STATUS .NE. -3 ))GOTO 23023
      IF (.NOT.(VRBS(LEVEL) .EQ. 1))GOTO 23025
      CALL PUTLIN(LIN, 3)
23025 CONTINUE
      I = 1
      CURSAV = CURLN
      IF (.NOT.( GETLST( LIN, I, STATUS) .EQ. 0 ))GOTO 23027
      IF (.NOT.( CKGLOB( LIN, I, STATUS) .EQ. 0 ))GOTO 23029
      STATUS = DOGLOB( LIN, I, STATUS)
      GOTO 23030
23029 CONTINUE
      IF (.NOT.( STATUS .NE. -3 .AND. STATUS .NE. -10 ))GOTO 23031
      STATUS = DOCMD( LIN, I, 0, STATUS)
23031 CONTINUE
23030 CONTINUE
23027 CONTINUE
23023 CONTINUE
      IF (.NOT.( STATUS .EQ. -3 ))GOTO 23033
      CALL REMARK( 2H?. )
      CURLN = CURSAV
      GOTO 23034
23033 CONTINUE
      IF (.NOT.( STATUS .EQ. -1 ))GOTO 23035
      IF (.NOT.(LEVEL .GT. 1))GOTO 23037
      GOTO 23020
23037 CONTINUE
      IF (.NOT.( CLRBUF(113) .EQ. 0 ))GOTO 23039
      CLEARD = 1
      GOTO 23020
23039 CONTINUE
23038 CONTINUE
23035 CONTINUE
23034 CONTINUE
23019 GOTO 23018
23020 CONTINUE
      IF (.NOT.(LEVEL .GT. 1))GOTO 23041
      CALL CLOSE(DESC(LEVEL))
23041 CONTINUE
23016 LEVEL = LEVEL - 1
      GOTO 23015
23017 CONTINUE
      IF (.NOT.(CLEARD .EQ. 0))GOTO 23043
      STATUS = CLRBUF(-1)
23043 CONTINUE
      CALL ENDED
      RETURN
      END
      INTEGER FUNCTION APPEND( LINE, GLOB)
      INTEGER INJECT, INPLIN
      INTEGER GLOB, LINE
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CSCLIN/ LIN(512)
      LOGICAL*1 LIN
      COMMON / CSTACK / LEVEL, VRBS(2), DESC(2)
      INTEGER LEVEL
      INTEGER VRBS
      INTEGER DESC
      IF (.NOT.( GLOB .EQ. 1 ))GOTO 23045
      APPEND=(-3)
      RETURN
23045 CONTINUE
      CURLN = LINE
23047 CONTINUE
      IF (.NOT.( INPLIN( LIN, DESC(LEVEL), CURLN + 1 ) .EQ. -1 ))GOTO 23
     *050
      APPEND=(-1)
      RETURN
23050 CONTINUE
      IF (.NOT.( LIN(1) .EQ. 46 .AND. LIN(2) .EQ. 10 ))GOTO 23052
      APPEND=(0)
      RETURN
23052 CONTINUE
      IF (.NOT.( INJECT(LIN) .EQ. -3 ))GOTO 23054
      APPEND=(-3)
      RETURN
23054 CONTINUE
23053 CONTINUE
23051 CONTINUE
23048 GOTO 23047
23049 CONTINUE
      END
      INTEGER FUNCTION BROWSE( LINE, LIN, I)
      LOGICAL*1 DIREC, LIN(100)
      INTEGER CURSCR, I, LIN1, LIN2, LINE, SCREEN
      INTEGER CTOI, DOPRNT
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      DATA SCREEN, CURSCR / 22, 22 /
      IF (.NOT.( LIN(I) .EQ. 10 ))GOTO 23056
      DIREC = 43
      SCREEN = CURSCR
      GOTO 23057
23056 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 43 .OR. LIN(I) .EQ. 46 .OR. LIN(I) .EQ. 45 
     *))GOTO 23058
      DIREC = LIN(I)
      I = I + 1
      GOTO 23059
23058 CONTINUE
      DIREC = 43
23059 CONTINUE
      SCREEN = CTOI( LIN, I) - 1
      IF (.NOT.( SCREEN .LE. 0 ))GOTO 23060
      SCREEN = CURSCR
      GOTO 23061
23060 CONTINUE
      CURSCR = SCREEN
23061 CONTINUE
23057 CONTINUE
      IF (.NOT.( DIREC .EQ. 43 ))GOTO 23062
      LIN1 = LINE
      GOTO 23063
23062 CONTINUE
      IF (.NOT.( DIREC .EQ. 46 ))GOTO 23064
      LIN1 = LINE - ( SCREEN / 2 )
      GOTO 23065
23064 CONTINUE
      LIN1 = LINE - SCREEN
23065 CONTINUE
23063 CONTINUE
      LIN2 = LIN1 + SCREEN
      LIN1 = MAX0( 1, LIN1)
      LIN2 = MIN0( LIN2, LASTLN)
      BROWSE = DOPRNT( LIN1, LIN2, 112)
      RETURN
      END
      SUBROUTINE CATSUB( LIN, FROM, TO, SUB, NEW, K, MAXNEW)
      INTEGER ADDSET, CTOI, ITOC
      INTEGER FROM, I, J, JUNK, K, MAXNEW, TO
      LOGICAL*1 C, LIN(512), NEW(MAXNEW), SUB(132)
      COMMON/CTAG/TAGLIM(20)
      INTEGER TAGLIM
      COMMON / CNOREG / NOREG
      INTEGER NOREG
      I = 1 
23066 IF (.NOT.(SUB(I) .NE. 0 ))GOTO 23068
      IF (.NOT.( SUB(I) .EQ. (-3) ))GOTO 23069
      J = FROM 
23071 IF (.NOT.(J .LT. TO ))GOTO 23073
      JUNK = ADDSET( LIN(J), NEW, K, MAXNEW)
23072 J = J + 1 
      GOTO 23071
23073 CONTINUE
      GOTO 23070
23069 CONTINUE
      IF (.NOT.( SUB(I) .EQ. (-4) ))GOTO 23074
      I = I + 1
      N = SUB(I)
      IF (.NOT.( N .LE. 0 .OR. N .GT. 10 ))GOTO 23076
      CALL ERROR( 29H? In CatSub: illegal section. )
23076 CONTINUE
      J = TAGLIM( 2 * N - 1 ) 
23078 IF (.NOT.(J .LT. TAGLIM( 2 * N ) ))GOTO 23080
      JUNK = ADDSET( LIN(J), NEW, K, MAXNEW)
23079 J = J + 1 
      GOTO 23078
23080 CONTINUE
      GOTO 23075
23074 CONTINUE
      IF (.NOT.( SUB(I) .EQ. (-5) ))GOTO 23081
      K = K + ITOC( NOREG, NEW(K), MAXNEW - K + 1 )
      I = I + 1
      C = SUB(I)
      IF (.NOT.( C .EQ. 43 .OR. C .EQ. 45 ))GOTO 23083
      I = I + 1
      IF (.NOT.( SUB(I) .NE. 32 .AND. SUB(I) .NE. 9 ))GOTO 23085
      JUNK = CTOI( SUB, I)
      IF (.NOT.( JUNK .EQ. 0 ))GOTO 23087
      JUNK = 1
23087 CONTINUE
      GOTO 23086
23085 CONTINUE
      JUNK = 1
23086 CONTINUE
      IF (.NOT.( C .EQ. 43 ))GOTO 23089
      NOREG = NOREG + JUNK
      GOTO 23090
23089 CONTINUE
      NOREG = NOREG - JUNK
23090 CONTINUE
23083 CONTINUE
      I = I - 1
      GOTO 23082
23081 CONTINUE
      JUNK = ADDSET( SUB(I), NEW, K, MAXNEW)
23082 CONTINUE
23075 CONTINUE
23070 CONTINUE
23067 I = I + 1 
      GOTO 23066
23068 CONTINUE
      RETURN
      END
      INTEGER FUNCTION CKGLOB( LIN, I, STATUS)
      LOGICAL*1 LIN(512)
      INTEGER DEFALT, GETIND, GETTXT, MATCH, NEXTLN, OPTPAT
      INTEGER GFLAG, I, K, LINE, STATUS
      LOGICAL*1 CLOWER
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CPAT/ PAT(132)
      INTEGER PAT
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      IF (.NOT.( CLOWER( LIN(I) ) .NE. 103 .AND. CLOWER( LIN(I) ) .NE. 1
     *20 ))GOTO 23091
      STATUS = -1
      GOTO 23092
23091 CONTINUE
      IF (.NOT.( CLOWER( LIN(I) ) .EQ. 103 ))GOTO 23093
      GFLAG = 1
      GOTO 23094
23093 CONTINUE
      GFLAG = 0
23094 CONTINUE
      I = I + 1
      IF (.NOT.( OPTPAT( LIN, I) .EQ. -3 .OR. DEFALT( 1, LASTLN, STATUS)
     * .EQ. -3 ))GOTO 23095
      STATUS = -3
      GOTO 23096
23095 CONTINUE
      I = I + 1
      LINE = LINE1 
23097 IF (.NOT.(LINE .LE. LINE2 ))GOTO 23099
      K = GETTXT(LINE)
      IF (.NOT.( MATCH( TXT, PAT) .EQ. GFLAG ))GOTO 23100
      CALL SETB( K, 3, 1)
      GOTO 23101
23100 CONTINUE
      CALL SETB( K, 3, 0)
23101 CONTINUE
23098 LINE = LINE + 1 
      GOTO 23097
23099 CONTINUE
      LINE = NEXTLN(LINE2) 
23102 IF (.NOT.(LINE .NE. LINE1 ))GOTO 23104
      K = GETIND(LINE)
      CALL SETB( K, 3, 0)
23103 LINE = NEXTLN(LINE) 
      GOTO 23102
23104 CONTINUE
      STATUS = 0
23096 CONTINUE
23092 CONTINUE
      CKGLOB=(STATUS)
      RETURN
      END
      INTEGER FUNCTION CKP( LIN, I, PFLAG, STATUS)
      LOGICAL*1 C, LIN(512)
      INTEGER I, J, PFLAG, STATUS
      LOGICAL*1 CLOWER
      J = I
      C = CLOWER( LIN(J) )
      IF (.NOT.( C .EQ. 112 .OR. C .EQ. 108 ))GOTO 23105
      J = J + 1
      PFLAG = C
      GOTO 23106
23105 CONTINUE
      PFLAG = 0
23106 CONTINUE
      IF (.NOT.( LIN(J) .EQ. 10 ))GOTO 23107
      STATUS = 0
      GOTO 23108
23107 CONTINUE
      STATUS = -3
23108 CONTINUE
      CKP=(STATUS)
      RETURN
      END
      INTEGER FUNCTION CLRBUF(COMAND)
      LOGICAL*1 COMAND
      INTEGER JUNK
      INTEGER ISATTY, PROMPT, REMOVE
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CSCLIN/ LIN(512)
      LOGICAL*1 LIN
      COMMON /CSCRAT/ SCR, SCREND(2) , SCRFIL(40)
      INTEGER SCR
      INTEGER SCREND
      LOGICAL*1 SCRFIL
      COMMON / CVFILE / VIRUNT, VIREND, VPFILE(40)
      INTEGER VIRUNT
      INTEGER*4 VIREND
      LOGICAL*1 VPFILE
      LOGICAL*1 PSTR(29)
      DATA PSTR(1)/65/,PSTR(2)/114/,PSTR(3)/101/,PSTR(4)/32/,PSTR(5)/121
     */,PSTR(6)/111/,PSTR(7)/117/,PSTR(8)/32/,PSTR(9)/83/,PSTR(10)/85/,P
     *STR(11)/82/,PSTR(12)/69/,PSTR(13)/63/,PSTR(14)/32/,PSTR(15)/40/,PS
     *TR(16)/121/,PSTR(17)/32/,PSTR(18)/109/,PSTR(19)/101/,PSTR(20)/97/,
     *PSTR(21)/110/,PSTR(22)/115/,PSTR(23)/32/,PSTR(24)/89/,PSTR(25)/69/
     *,PSTR(26)/83/,PSTR(27)/41/,PSTR(28)/32/,PSTR(29)/0/
      IF (.NOT.( COMAND .NE. -1 .AND. IFMOD .EQ. 1 .AND. ISATTY(1) .EQ. 
     *1 ))GOTO 23109
      JUNK = PROMPT( PSTR, LIN, 1)
      IF (.NOT.( LIN(1) .NE. 121 .AND. LIN(1) .NE. 89 ))GOTO 23111
      CLRBUF=(-3)
      RETURN
23111 CONTINUE
23109 CONTINUE
      CALL CLOSE(SCR)
      JUNK = REMOVE(SCRFIL)
      IF (.NOT.(VIRUNT .NE. -3))GOTO 23113
      CALL CLOSE(VIRUNT)
      JUNK = REMOVE(VPFILE)
      CALL VIRINT
23113 CONTINUE
      CLRBUF=(0)
      RETURN
      END
      INTEGER FUNCTION CONCT( NBR, LIN)
      INTEGER I, JUNK, NBR
      INTEGER GETTXT
      LOGICAL*1 LIN(100)
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      I = 1 
23115 IF (.NOT.(LIN(I) .NE. 0 ))GOTO 23117
      IF (.NOT.( LIN(I) .EQ. 10 ))GOTO 23118
      CONCT=(0)
      RETURN
23118 CONTINUE
23116 I = I + 1 
      GOTO 23115
23117 CONTINUE
      IF (.NOT.( NBR + 1 .GT. LASTLN ))GOTO 23120
      CONCT=(-3)
      RETURN
23120 CONTINUE
      JUNK = GETTXT( NBR + 1 )
      CALL SCOPY( TXT, 1, LIN, I)
      CALL DELETE( NBR + 1, NBR + 1, JUNK)
      CONCT=(0)
      RETURN
      END
      INTEGER FUNCTION DEFALT( DEF1, DEF2, STATUS)
      INTEGER DEF1, DEF2, STATUS
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      IF (.NOT.( NLINES .EQ. 0 ))GOTO 23122
      LINE1 = DEF1
      LINE2 = DEF2
23122 CONTINUE
      IF (.NOT.( LINE1 .GT. LINE2 .OR. LINE1 .LE. 0 ))GOTO 23124
      STATUS = -3
      GOTO 23125
23124 CONTINUE
      STATUS = 0
23125 CONTINUE
      DEFALT=(STATUS)
      RETURN
      END
      INTEGER FUNCTION DELETE( FROM, TO, STATUS)
      INTEGER GETIND, NEXTLN, PREVLN
      INTEGER FROM, K1, K2, STATUS, TO
      COMMON /CDEL/ DELCNT, FSTDEL, LSTDEL
      INTEGER DELCNT
      INTEGER FSTDEL
      INTEGER LSTDEL
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      IF (.NOT.( FROM .LE. 0 ))GOTO 23126
      STATUS = -3
      GOTO 23127
23126 CONTINUE
      IF (.NOT.( DELCNT .NE. 0 ))GOTO 23128
      CALL PTFNDX( FSTDEL, LSTDEL)
23128 CONTINUE
      FSTDEL = GETIND(FROM)
      LSTDEL = GETIND(TO)
      K1 = GETIND( PREVLN(FROM) )
      K2 = GETIND( NEXTLN(TO) )
      DELCNT = TO - FROM + 1
      LASTLN = LASTLN - DELCNT
      CURLN = PREVLN(FROM)
      CALL RELINK( K1, K2, K1, K2)
      STATUS = 0
23127 CONTINUE
      DELETE=(STATUS)
      RETURN
      END
      INTEGER FUNCTION DOCMD( LIN, I, GLOB, STATUS)
      LOGICAL*1 FILE(512), LIN(512), SUB(132)
      LOGICAL*1 CLOWER, COMAND
      INTEGER APPEND, DELETE, DOPRNT, DOREAD, DOWRIT, LMOVE, SUBST, UNDE
     *L
      INTEGER CKP, DEFALT, GETFN, GETONE, GETRHS, NEXTLN, OPTPAT, PREVLN
      INTEGER TYPSET, DOJOIN, DONREG, DOPIP, DOSET
      INTEGER GFLAG, GLOB, I, LINE3, PFLAG, STATUS, KOPY, DOSPWN, BROWSE
      INTEGER CLRBUF, DOSTAK
      COMMON /CFILE/ SAVFIL(40)
      LOGICAL*1 SAVFIL
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CPAT/ PAT(132)
      INTEGER PAT
      PFLAG = 0
      STATUS = -3
      COMAND = CLOWER( LIN(I))
      I = I + 1
      IF (.NOT.( COMAND .EQ. 115 ))GOTO 23130
      IF (.NOT.( LIN(I) .EQ. 101 .OR. LIN(I) .EQ. 69 ))GOTO 23132
      STATUS = DOSET( LIN, I)
      DOCMD=(STATUS)
      RETURN
23132 CONTINUE
23130 CONTINUE
      I23134=(COMAND)
      GOTO 23134
23136 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 10 ))GOTO 23137
      STATUS = APPEND( LINE2, GLOB)
23137 CONTINUE
      GOTO 23135
23139 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 10 ))GOTO 23140
      IF (.NOT.( DEFALT( CURLN, CURLN, STATUS) .EQ. 0 ))GOTO 23142
      IF (.NOT.( DELETE( LINE1, LINE2, STATUS) .EQ. 0 ))GOTO 23144
      STATUS = APPEND( PREVLN(LINE1), GLOB)
23144 CONTINUE
23142 CONTINUE
23140 CONTINUE
      GOTO 23135
23146 CONTINUE
      IF (.NOT.( CKP( LIN, I, PFLAG, STATUS) .EQ. 0 ))GOTO 23147
      IF (.NOT.( DEFALT( CURLN, CURLN, STATUS) .EQ. 0 ))GOTO 23149
      IF (.NOT.( DELETE( LINE1, LINE2, STATUS) .EQ. 0 ))GOTO 23151
      IF (.NOT.( NEXTLN(CURLN) .NE. 0 ))GOTO 23153
      CURLN = NEXTLN(CURLN)
23153 CONTINUE
23151 CONTINUE
23149 CONTINUE
23147 CONTINUE
      GOTO 23135
23155 CONTINUE
      CALL DOHELP
      STATUS = 0
      GOTO 23135
23156 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 10 ))GOTO 23157
      STATUS = APPEND( PREVLN(LINE2), GLOB)
23157 CONTINUE
      GOTO 23135
23159 CONTINUE
      IF (.NOT.( CKP( LIN, I, PFLAG, STATUS) .EQ. 0 ))GOTO 23160
      IF (.NOT.( DEFALT( CURLN, NEXTLN(CURLN), STATUS) .EQ. 0 ))GOTO 231
     *62
      STATUS = DOJOIN( LINE1, LINE2)
23162 CONTINUE
23160 CONTINUE
      GOTO 23135
23164 CONTINUE
      IF (.NOT.( CKP(LIN, I, PFLAG, STATUS) .EQ. 0 ))GOTO 23165
      CALL PUTINT( LINE2, 1,2)
      CALL PUTCH(10,2)
23165 CONTINUE
      GOTO 23135
23167 CONTINUE
      STATUS = DONREG( LIN, I)
      GOTO 23135
23168 CONTINUE
      IF (.NOT.( GETONE( LIN, I, LINE3, STATUS) .EQ. -1 ))GOTO 23169
      STATUS = -3
23169 CONTINUE
      IF (.NOT.( STATUS .EQ. 0 ))GOTO 23171
      IF (.NOT.( CKP( LIN, I, PFLAG, STATUS) .EQ. 0 ))GOTO 23173
      IF (.NOT.( DEFALT( CURLN, CURLN, STATUS) .EQ. 0 ))GOTO 23175
      STATUS = LMOVE(LINE3)
23175 CONTINUE
23173 CONTINUE
23171 CONTINUE
      GOTO 23135
23177 CONTINUE
      IF (.NOT.( GETONE( LIN, I, LINE3, STATUS) .EQ. -1 ))GOTO 23178
      STATUS = -3
23178 CONTINUE
      IF (.NOT.( STATUS .EQ. 0 ))GOTO 23180
      IF (.NOT.( CKP( LIN, I, PFLAG, STATUS) .EQ. 0 ))GOTO 23182
      IF (.NOT.( DEFALT( CURLN, CURLN, STATUS) .EQ. 0 ))GOTO 23184
      STATUS = KOPY(LINE3)
23184 CONTINUE
23182 CONTINUE
23180 CONTINUE
      GOTO 23135
23186 CONTINUE
      IF (.NOT.( OPTPAT( LIN, I) .EQ. 0 ))GOTO 23187
      IF (.NOT.( GETRHS( LIN, I, SUB, GFLAG) .EQ. 0 ))GOTO 23189
      IF (.NOT.( CKP( LIN, I + 1, PFLAG, STATUS) .EQ. 0 ))GOTO 23191
      IF (.NOT.( DEFALT( CURLN, CURLN, STATUS) .EQ. 0 ))GOTO 23193
      STATUS = SUBST( SUB, GFLAG)
23193 CONTINUE
23191 CONTINUE
23189 CONTINUE
23187 CONTINUE
      GOTO 23135
23195 CONTINUE
      STATUS = DOSPWN( LIN, I)
      GOTO 23135
23196 CONTINUE
      IF (.NOT.( NLINES .EQ. 0 ))GOTO 23197
      IF (.NOT.( GETFN( LIN, I, FILE) .EQ. 0 ))GOTO 23199
      IF (.NOT.( CLRBUF(101) .EQ. 0 ))GOTO 23201
      CALL STRCPY( FILE, SAVFIL)
      CALL SETBUF
      STATUS = DOREAD( 0, FILE, 101)
      GOTO 23202
23201 CONTINUE
      STATUS = 0
23202 CONTINUE
23199 CONTINUE
23197 CONTINUE
      GOTO 23135
23203 CONTINUE
      IF (.NOT.( NLINES .EQ. 0 ))GOTO 23204
      IF (.NOT.( GETFN( LIN, I, FILE) .EQ. 0 ))GOTO 23206
      CALL STRCPY( FILE, SAVFIL)
      CALL PUTLIN(SAVFIL, 2)
      CALL PUTCH(10,2)
      STATUS = 0
23206 CONTINUE
23204 CONTINUE
      GOTO 23135
23208 CONTINUE
      IF (.NOT.( GETFN( LIN, I, FILE) .EQ. 0 ))GOTO 23209
      STATUS = DOREAD( LINE2, FILE, 114)
23209 CONTINUE
      GOTO 23135
23211 CONTINUE
      IF (.NOT.( GETFN( LIN, I, FILE) .EQ. 0 ))GOTO 23212
      IF (.NOT.( DEFALT( 1, LASTLN, STATUS) .EQ. 0 ))GOTO 23214
      STATUS = DOWRIT( LINE1, LINE2, FILE)
23214 CONTINUE
23212 CONTINUE
      GOTO 23135
23216 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 10 ))GOTO 23217
      IF (.NOT.( DEFALT( CURLN, CURLN, STATUS) .EQ. 0 ))GOTO 23219
      STATUS = DOPRNT( LINE1, LINE2, COMAND)
23219 CONTINUE
23217 CONTINUE
      GOTO 23135
23221 CONTINUE
      IF (.NOT.( DEFALT( CURLN, CURLN, STATUS) .EQ. 0 ))GOTO 23222
      STATUS = BROWSE( LINE2, LIN, I)
23222 CONTINUE
      GOTO 23135
23224 CONTINUE
      STATUS = 0
      GOTO 23135
23225 CONTINUE
      IF (.NOT.( NLINES .EQ. 0 ))GOTO 23226
      LINE2 = PREVLN(CURLN)
23226 CONTINUE
      STATUS = DOPRNT( LINE2, LINE2, 112)
      GOTO 23135
23228 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 10 .AND. NLINES .EQ. 0 .AND. GLOB .EQ. 0 ))
     *GOTO 23229
      STATUS = -1
23229 CONTINUE
      GOTO 23135
23231 CONTINUE
      STATUS = TYPSET( LIN, I)
      GOTO 23135
23232 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 10 ))GOTO 23233
      STATUS = UNDEL( LINE2, GLOB)
23233 CONTINUE
      GOTO 23135
23235 CONTINUE
      CALL PERCEN
      STATUS = 0
      GOTO 23135
23236 CONTINUE
      IF (.NOT.(DEFALT(1, LASTLN, STATUS) .EQ. 0))GOTO 23237
      STATUS = DOPIP( LINE1, LINE2, LIN, I)
23237 CONTINUE
      GOTO 23135
23239 CONTINUE
      STATUS = DOSTAK(LIN, I)
      GOTO 23135
23240 CONTINUE
      IF (.NOT.( NLINES .EQ. 0 ))GOTO 23241
      LINE2 = NEXTLN(CURLN)
23241 CONTINUE
      STATUS = DOPRNT( LINE2, LINE2, 112)
      GOTO 23135
23134 CONTINUE
      IF (I23134.EQ.10)GOTO 23240
      IF (I23134.EQ.35)GOTO 23224
      IF (I23134.EQ.37)GOTO 23235
      IF (I23134.EQ.45)GOTO 23225
      IF (I23134.EQ.60)GOTO 23239
      IF (I23134.EQ.61)GOTO 23164
      IF (I23134.EQ.94)GOTO 23195
      IF (I23134.EQ.97)GOTO 23136
      IF (I23134.EQ.98)GOTO 23221
      IF (I23134.EQ.99)GOTO 23139
      IF (I23134.EQ.100)GOTO 23146
      IF (I23134.EQ.101)GOTO 23196
      IF (I23134.EQ.102)GOTO 23203
      IF (I23134.EQ.104)GOTO 23155
      IF (I23134.EQ.105)GOTO 23156
      IF (I23134.EQ.106)GOTO 23159
      IF (I23134.EQ.107)GOTO 23177
      IF (I23134.EQ.108)GOTO 23216
      IF (I23134.EQ.109)GOTO 23168
      IF (I23134.EQ.110)GOTO 23167
      IF (I23134.EQ.112)GOTO 23216
      IF (I23134.EQ.113)GOTO 23228
      IF (I23134.EQ.114)GOTO 23208
      IF (I23134.EQ.115)GOTO 23186
      IF (I23134.EQ.116)GOTO 23231
      IF (I23134.EQ.117)GOTO 23232
      IF (I23134.EQ.119)GOTO 23211
      IF (I23134.EQ.124)GOTO 23236
23135 CONTINUE
      IF (.NOT.( STATUS .EQ. 0 ))GOTO 23243
      IF (.NOT.( PFLAG .EQ. 112 .OR. PFLAG .EQ. 108 ))GOTO 23245
      STATUS = DOPRNT( CURLN, CURLN, PFLAG)
23245 CONTINUE
23243 CONTINUE
      DOCMD=(STATUS)
      RETURN
      END
      INTEGER FUNCTION DOGLOB( LIN, I, STATUS)
      LOGICAL*1 LIN(512)
      INTEGER DOCMD, GETIND, GETLST, NEXTLN, PROMPT
      INTEGER VALUE(2)
      INTEGER COUNT, I, ISTART, K, LINE, STATUS, LAST
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON / CSTACK / LEVEL, VRBS(2), DESC(2)
      INTEGER LEVEL
      INTEGER VRBS
      INTEGER DESC
      LOGICAL*1 GPSTR(3)
      DATA GPSTR(1)/103/,GPSTR(2)/95/,GPSTR(3)/0/
      LAST = LENGTH(LIN) 
23247 IF (.NOT.(LIN( LAST - 1 ) .EQ. 64 ))GOTO 23249
      LIN( LAST - 1 ) = 10
      JUNK = PROMPT( GPSTR, LIN(LAST), DESC(LEVEL))
23248 LAST = LENGTH(LIN) 
      GOTO 23247
23249 CONTINUE
      STATUS = 0
      COUNT = 0
      LINE = LINE1
      ISTART = I
23250 CONTINUE
      K = GETIND(LINE)
      CALL GETB( K, 3, VALUE)
      IF (.NOT.( VALUE(1) .EQ. 1 ))GOTO 23253
      CALL SETB( K, 3, 0)
      CURSAV = LINE
      I = ISTART
23255 CONTINUE
      CURLN = LINE
      IF (.NOT.( GETLST( LIN, I, STATUS) .EQ. 0 ))GOTO 23258
      IF (.NOT.( DOCMD( LIN, I, 1, STATUS) .EQ. 0 ))GOTO 23260
      COUNT = 0
23260 CONTINUE
23258 CONTINUE
23262 IF (.NOT.( LIN(I) .NE. 10 ))GOTO 23263
      I = I + 1
      GOTO 23262
23263 CONTINUE
      I = I + 1
      IF (.NOT.( LIN(I) .EQ. 0 ))GOTO 23264
      GOTO 23257
23264 CONTINUE
23256 GOTO 23255
23257 CONTINUE
      GOTO 23254
23253 CONTINUE
      LINE = NEXTLN(LINE)
      COUNT = COUNT + 1
23254 CONTINUE
23251 IF (.NOT.( COUNT .GT. LASTLN .OR. STATUS .NE. 0 ))GOTO 23250
23252 CONTINUE
      DOGLOB=(STATUS)
      RETURN
      END
      SUBROUTINE DOHELP
      INTEGER OPEN
      INTEGER FD
      LOGICAL*1 HLPFIL(12)
      DATA HLPFIL(1)/126/,HLPFIL(2)/98/,HLPFIL(3)/105/,HLPFIL(4)/110/,HL
     *PFIL(5)/47/,HLPFIL(6)/101/,HLPFIL(7)/100/,HLPFIL(8)/46/,HLPFIL(9)/
     *104/,HLPFIL(10)/108/,HLPFIL(11)/112/,HLPFIL(12)/0/
      FD = OPEN( HLPFIL, 1)
      IF (.NOT.( FD .NE. -3 ))GOTO 23266
      CALL FCOPY( FD, 2)
      CALL CLOSE(FD)
      GOTO 23267
23266 CONTINUE
      CALL REMARK( 28HSorry, no help is available. )
23267 CONTINUE
      RETURN
      END
      INTEGER FUNCTION DOJOIN( FROM, TO)
      INTEGER FROM, TO
      INTEGER I, J, JUNK, K, SAVCLN, STATUS
      INTEGER DELETE, GETTXT, INJEXT, PREVLN
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CSCLIN/ LIN(512)
      LOGICAL*1 LIN
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      IF (.NOT.( FROM .LE. 0 ))GOTO 23268
      STATUS = -3
      GOTO 23269
23268 CONTINUE
      STATUS = 0
      IF (.NOT.( FROM .LT. TO ))GOTO 23270
      J = 1
      I = FROM 
23272 IF (.NOT.(I .LE. TO ))GOTO 23274
      JUNK = GETTXT(I)
      IF (.NOT.( 1 .LT. J .AND. J .LT. 511 ))GOTO 23275
      IF (.NOT.( LIN( J - 1 ) .NE. 32 .AND. LIN( J - 1 ) .NE. 9 ))GOTO 2
     *3277
      IF (.NOT.( TXT(1) .NE. 32 .AND. TXT(1) .NE. 9 ))GOTO 23279
      LIN(J) = 32
      J = J + 1
23279 CONTINUE
23277 CONTINUE
23275 CONTINUE
      K = 1 
23281 IF (.NOT.(TXT(K) .NE. 10 .AND. TXT(K) .NE. 0 ))GOTO 23283
      IF (.NOT.( J .GE. 511 ))GOTO 23284
      STATUS = -3
      GOTO 23274
23284 CONTINUE
      LIN(J) = TXT(K)
      J = J + 1
23285 CONTINUE
23282 K = K + 1 
      GOTO 23281
23283 CONTINUE
23273 I = I + 1 
      GOTO 23272
23274 CONTINUE
      LIN(J) = 10
      LIN( J + 1 ) = 0
      IF (.NOT.( STATUS .EQ. 0 ))GOTO 23286
      SAVCLN = CURLN
      CURLN = PREVLN(CURLN)
      IF (.NOT.( DELETE( FROM, TO, STATUS) .EQ. 0 ))GOTO 23288
      STATUS = INJECT(LIN)
      GOTO 23289
23288 CONTINUE
      CURLN = SAVCLN
23289 CONTINUE
23286 CONTINUE
23270 CONTINUE
23269 CONTINUE
      DOJOIN=(STATUS)
      RETURN
      END
      INTEGER FUNCTION DONREG( LIN, I)
      LOGICAL*1 LIN(100), OP
      INTEGER DIF, I, J, PFLAG, STATUS
      INTEGER CTOI, INDEXC
      COMMON / CNOREG / NOREG
      INTEGER NOREG
      LOGICAL*1 LEGAL(4)
      DATA LEGAL(1)/61/,LEGAL(2)/43/,LEGAL(3)/45/,LEGAL(4)/0/
      STATUS = 0
      PFLAG = 0
      IF (.NOT.( LIN(I) .EQ. 10 ))GOTO 23290
      PFLAG = 1
      GOTO 23291
23290 CONTINUE
      OP = LIN(I)
      IF (.NOT.( INDEXC( LEGAL, OP) .EQ. 0 ))GOTO 23292
      STATUS = -3
      GOTO 23293
23292 CONTINUE
      J = I + 1
      DIF = CTOI( LIN, J)
      IF (.NOT.( DIF .EQ. 0 .AND. OP .NE. 61 ))GOTO 23294
      DIF = 1
23294 CONTINUE
      IF (.NOT.( OP .EQ. 43 ))GOTO 23296
      NOREG = NOREG + DIF
      GOTO 23297
23296 CONTINUE
      IF (.NOT.( OP .EQ. 61 ))GOTO 23298
      NOREG = DIF
      GOTO 23299
23298 CONTINUE
      NOREG = NOREG - DIF
23299 CONTINUE
23297 CONTINUE
      IF (.NOT.( LIN(J) .EQ. 112 .OR. LIN(J) .EQ. 80 ))GOTO 23300
      PFLAG = 1
23300 CONTINUE
23293 CONTINUE
23291 CONTINUE
      IF (.NOT.( STATUS .EQ. 0 .AND. PFLAG .EQ. 1 ))GOTO 23302
      CALL PUTINT( NOREG, 1,2)
      CALL PUTCH(10,2)
23302 CONTINUE
      DONREG=(STATUS)
      RETURN
      END
      INTEGER FUNCTION DOPIP( L1, L2, LIN, I)
      INTEGER DOSPWN, DOWRIT, GETWRD, LENGTH, REMOVE
      INTEGER I, J, K, LEN, MODTMP, PRTTMP, STATUS, L1, L2, JUNK
      LOGICAL*1 LIN(100)
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON / CSPWN / ARGARA(256), FILARA(40)
      LOGICAL*1 ARGARA
      LOGICAL*1 FILARA
      LOGICAL*1 BLKLES(3)
      LOGICAL*1 SEED(4)
      DATA BLKLES(1)/32/,BLKLES(2)/60/,BLKLES(3)/0/
      DATA SEED(1)/112/,SEED(2)/105/,SEED(3)/112/,SEED(4)/0/
      MODTMP = IFMOD
      PRTTMP = PRINT
      PRINT = 0
      CALL SCRATF( SEED, FILARA)
      IF (.NOT.( DOWRIT( L1, L2, FILARA) .NE. -3 ))GOTO 23304
      J = I
      LEN = GETWRD( LIN, J, ARGARA)
      K = J
      J = LEN + 1
      CALL STCOPY( BLKLES, 1, ARGARA, J)
      CALL STCOPY( FILARA, 1, ARGARA, J)
      CALL STCOPY( LIN, K, ARGARA, J)
      J = 1
      STATUS = DOSPWN( ARGARA, J)
      GOTO 23305
23304 CONTINUE
      CALL REMARK( 28H? Can't create scratch file. )
      STATUS = -3
23305 CONTINUE
      JUNK = REMOVE(FILARA)
      IFMOD = MODTMP
      PRINT = PRTTMP
      DOPIP=(STATUS)
      RETURN
      END
      INTEGER FUNCTION DOPRNT( FROM, TO, COMAND)
      INTEGER GETTXT
      INTEGER FROM, I, J, K, TO
      LOGICAL*1 C, COMAND
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      IF (.NOT.( FROM .LE. 0 ))GOTO 23306
      DOPRNT=(-3)
      RETURN
23306 CONTINUE
      I = FROM 
23308 IF (.NOT.(I .LE. TO ))GOTO 23310
      J = GETTXT(I)
      CALL PTLNUM( I, 2)
      IF (.NOT.( COMAND .EQ. 112 ))GOTO 23311
      CALL PUTLIN( TXT, 2)
      GOTO 23312
23311 CONTINUE
      K = 1 
23313 IF (.NOT.(TXT(K) .NE. 0 ))GOTO 23315
      IF (.NOT.( TXT(K) .GE. 32 ))GOTO 23316
      CALL PUTCH( TXT(K), 2)
      GOTO 23317
23316 CONTINUE
      IF (.NOT.( TXT(K) .EQ. 10 ))GOTO 23318
      CALL PUTCH( 36, 2)
      CALL PUTCH( 10, 2)
      GOTO 23319
23318 CONTINUE
      CALL PUTCH( 94, 2)
      C = TXT(K) + 64
      CALL PUTCH( C, 2)
23319 CONTINUE
23317 CONTINUE
23314 K = K + 1 
      GOTO 23313
23315 CONTINUE
23312 CONTINUE
23309 I = I + 1 
      GOTO 23308
23310 CONTINUE
      CURLN = TO
      DOPRNT=(0)
      RETURN
23307 CONTINUE
      END
      INTEGER FUNCTION DOREAD( LINE, FILE, COMAND)
      LOGICAL*1 COMAND, FILE(512)
      INTEGER FD
      INTEGER OPEN
      INTEGER ACCESS, GETLIN, INJECT, REMOVE
      INTEGER COUNT, LINE, JUNK
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CFILE/ SAVFIL(40)
      LOGICAL*1 SAVFIL
      COMMON /CSCLIN/ LIN(512)
      LOGICAL*1 LIN
      COMMON / CSTACK / LEVEL, VRBS(2), DESC(2)
      INTEGER LEVEL
      INTEGER VRBS
      INTEGER DESC
      IF (.NOT.( COMAND .EQ. 101 ))GOTO 23320
      ACCESS = 3
      GOTO 23321
23320 CONTINUE
      ACCESS = 1
23321 CONTINUE
      CALL FINDIT( FILE, LIN)
      FD = OPEN( LIN, ACCESS)
      IF (.NOT.( FD .EQ. -3 ))GOTO 23322
      DOREAD=(-3)
      RETURN
23322 CONTINUE
      CURLN = LINE
      DOREAD = 0
      COUNT = 0 
23324 IF (.NOT.(GETLIN( LIN, FD) .NE. -1 ))GOTO 23326
      DOREAD = INJECT(LIN)
      IF (.NOT.( DOREAD .EQ. -3 ))GOTO 23327
      GOTO 23326
23327 CONTINUE
23325 COUNT = COUNT + 1 
      GOTO 23324
23326 CONTINUE
      CALL CLOSE(FD)
      IF (.NOT.((PRINT .EQ. 1 .AND. LEVEL .EQ. 1) .OR. VRBS(LEVEL) .EQ. 
     *1))GOTO 23329
      CALL PUTINT( COUNT, 1,2)
      CALL PUTCH(10,2)
23329 CONTINUE
      IF (.NOT.( COMAND .EQ. 101 ))GOTO 23331
      IFMOD = 0
      IF (.NOT.( COUNT .EQ. 0 ))GOTO 23333
      JUNK = REMOVE(FILE)
23333 CONTINUE
23331 CONTINUE
23323 CONTINUE
      RETURN
      END
      INTEGER FUNCTION DOSET( LIN, NDX)
      LOGICAL*1 CMDWRD(40), LIN(100)
      INTEGER I, J, JUNK, NDX, SET
      INTEGER GETWRD, INDEXS
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      I = NDX + 1
      IF (.NOT.( LIN(I) .EQ. 116 .OR. LIN(I) .EQ. 84 ))GOTO 23335
      I = I + 1
23335 CONTINUE
      JUNK = GETWRD( LIN, I, CMDWRD)
      CALL FOLD(CMDWRD)
      IF (.NOT.( CMDWRD(1) .EQ. 110 .AND. CMDWRD(2) .EQ. 111 ))GOTO 2333
     *7
      SET = 0
      J = 3
      GOTO 23338
23337 CONTINUE
      SET = 1
      J = 1
23338 CONTINUE
      IF (.NOT.( CMDWRD(J) .EQ. 97 ))GOTO 23339
      AUTOIN = SET
      GOTO 23340
23339 CONTINUE
      IF (.NOT.( CMDWRD(J) .EQ. 110 ))GOTO 23341
      NUMBER = SET
      GOTO 23342
23341 CONTINUE
      DOSET=(-3)
      RETURN
23342 CONTINUE
23340 CONTINUE
      DOSET=(0)
      RETURN
      END
      INTEGER FUNCTION DOSPWN(LIN, I)
      LOGICAL*1 LIN(100), PROCES(40), ARGS(256), DESC(7)
      INTEGER I, J, SSPAWN, INIT, K, INT, CREATE, LOCCOM
      COMMON / CTBUFS / EDTBUF(40, 3)
      LOGICAL*1 EDTBUF
      LOGICAL*1 SH(3)
      LOGICAL*1 SUFFIX(7)
      DATA SH(1)/115/,SH(2)/104/,SH(3)/0/
      DATA SUFFIX(1)/46/,SUFFIX(2)/116/,SUFFIX(3)/115/,SUFFIX(4)/107/,SU
     *FFIX(5)/0/,SUFFIX(6)/10/,SUFFIX(7)/0/
      DATA INIT / 1 /
      IF (.NOT.( INIT .EQ. 1 ))GOTO 23343
      CALL IMPATH(ARGS)
      IF (.NOT.( LOCCOM( SH, ARGS, SUFFIX, PROCES) .NE. 60 ))GOTO 23345
      CALL REMARK( 30H? Cannot find `sh' image file. )
      DOSPWN=(-3)
      RETURN
23345 CONTINUE
      K = 1
      CALL STCOPY( SH, 1, ARGS, K)
      CALL CHCOPY( 32, ARGS, K)
      J = 1 
23347 IF (.NOT.(J .LE. 3 ))GOTO 23349
      CALL STCOPY( EDTBUF( 1, J), 1, ARGS, K)
      ARGS(K) = 32
      K = K + 1
23348 J = J + 1 
      GOTO 23347
23349 CONTINUE
      ARGS(K) = 0
      INIT = 0
23343 CONTINUE
      CALL SKIPBL( LIN, I)
      IF (.NOT.(LIN(I) .EQ. 10 .OR. LIN(I) .EQ. 0))GOTO 23350
      STATUS = SSPAWN(PROCES, SH, DESC, 119)
      GOTO 23351
23350 CONTINUE
      INT = CREATE (EDTBUF(1,1), 2)
      IF (.NOT.(INT .EQ. -3))GOTO 23352
      STATUS = -3
      GOTO 23353
23352 CONTINUE
      J=I
23354 IF (.NOT.(LIN(J) .NE. 0))GOTO 23356
      CALL PUTCH(LIN(J), INT)
23355 J=J+1
      GOTO 23354
23356 CONTINUE
      CALL CLOSE(INT)
      STATUS = SSPAWN(PROCES, ARGS, DESC, 119)
23353 CONTINUE
23351 CONTINUE
      IF (.NOT.(STATUS .NE. 0))GOTO 23357
      STATUS = -3
23357 CONTINUE
      DOSPWN=(STATUS)
      RETURN
      END
      INTEGER FUNCTION DOSTAK(LINE, I)
      LOGICAL*1 LINE(100), FILE(40)
      INTEGER I
      INTEGER GETWRD, LOCCOM, INDEXC
      INTEGER UNIT
      INTEGER OPEN
      COMMON / CSTACK / LEVEL, VRBS(2), DESC(2)
      INTEGER LEVEL
      INTEGER VRBS
      INTEGER DESC
      COMMON /CSCLIN/ LIN(512)
      LOGICAL*1 LIN
      LOGICAL*1 SUFFIX(6)
      DATA SUFFIX(1)/46/,SUFFIX(2)/101/,SUFFIX(3)/100/,SUFFIX(4)/0/,SUFF
     *IX(5)/10/,SUFFIX(6)/0/
      IF (.NOT.(LEVEL .GE. 2))GOTO 23359
      DOSTAK=(-3)
      RETURN
23359 CONTINUE
      IF (.NOT.(GETWRD(LINE, I, LIN) .EQ. 0))GOTO 23361
      DOSTAK=(-3)
      RETURN
23361 CONTINUE
      CALL FINDIT(LIN, FILE)
      CALL IMPATH(LIN)
      IF (.NOT.(LOCCOM(FILE, LIN, SUFFIX, FILE) .NE. 12))GOTO 23363
      DOSTAK=(-3)
      RETURN
23363 CONTINUE
      UNIT = OPEN(FILE, 1)
      LEVEL = LEVEL + 1
      DESC(LEVEL) = UNIT
      VRBS(LEVEL) = 0
      IF (.NOT.(GETWRD(LINE, I, FILE) .GT. 0))GOTO 23365
      CALL FOLD(FILE)
      IF (.NOT.(INDEXC(FILE, 118) .GT. 0))GOTO 23367
      VRBS(LEVEL) = 1
23367 CONTINUE
23365 CONTINUE
23364 CONTINUE
23362 CONTINUE
23360 CONTINUE
      DOSTAK=(0)
      RETURN
      END
      INTEGER FUNCTION DOWRIT( FROM, TO, FILE)
      LOGICAL*1 FILE(512), LIN(40)
      INTEGER FD
      INTEGER CREATE, GETTXT
      INTEGER FROM, K, LINE, TO, ACCESS
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CFILE/ SAVFIL(40)
      LOGICAL*1 SAVFIL
      COMMON / CSTACK / LEVEL, VRBS(2), DESC(2)
      INTEGER LEVEL
      INTEGER VRBS
      INTEGER DESC
      ACCESS = 2
      K = 1
      IF (.NOT.(FILE(1) .EQ. 62))GOTO 23369
      K = 2
      IF (.NOT.(FILE(2) .EQ. 62))GOTO 23371
      K = 3
      ACCESS = 4
23371 CONTINUE
23369 CONTINUE
      CALL SCOPY(FILE, K, TXT, 1)
      CALL FINDIT( TXT, LIN)
      FD = CREATE( LIN, ACCESS)
      IF (.NOT.( FD .EQ. -3 ))GOTO 23373
      CALL PUTLIN( 33H? Can't write output file named `, 3)
      CALL PUTLIN( FILE, 3)
      CALL REMARK( 2H'. )
      DOWRIT=(-3)
      RETURN
23373 CONTINUE
      LINE = FROM 
23375 IF (.NOT.(LINE .LE. TO ))GOTO 23377
      K = GETTXT(LINE)
      CALL PUTLIN( TXT, FD)
23376 LINE = LINE + 1 
      GOTO 23375
23377 CONTINUE
      CALL CLOSE(FD)
      IF (.NOT.((PRINT .EQ. 1 .AND. LEVEL .EQ. 1) .OR. VRBS(LEVEL) .EQ. 
     *1))GOTO 23378
      CALL PUTINT( TO - FROM + 1, 1,2)
      CALL PUTCH(10,2)
23378 CONTINUE
      IFMOD = 0
      DOWRIT=(0)
      RETURN
23374 CONTINUE
      END
      SUBROUTINE ENDED
      INTEGER I, JUNK
      INTEGER REMOVE
      COMMON / CTBUFS / EDTBUF(40, 3)
      LOGICAL*1 EDTBUF
      I = 1 
23380 IF (.NOT.(I .LE. 3 ))GOTO 23382
      JUNK = REMOVE( EDTBUF( 1, I) )
23381 I = I + 1 
      GOTO 23380
23382 CONTINUE
      RETURN
      END
      SUBROUTINE FINDIT( IN, OUT)
      LOGICAL*1 IN(100), OUT(100)
      INTEGER I, N
      INTEGER CTOI
      COMMON / CTBUFS / EDTBUF(40, 3)
      LOGICAL*1 EDTBUF
      CALL STRCPY( IN, OUT)
      IF (.NOT.( IN(1) .EQ. 36 ))GOTO 23383
      I = 2
      N = CTOI( IN, I) + 1
      IF (.NOT.( 1 .LT. N .AND. N .LE. 3 ))GOTO 23385
      CALL STRCPY( EDTBUF( 1, N), OUT)
23385 CONTINUE
23383 CONTINUE
      RETURN
      END
      SUBROUTINE GETB( VIRNDX, TYPE, VALUE)
      INTEGER VIRNDX, TYPE, NDX
      INTEGER VALUE(2)
      INTEGER XINDEX
      INTEGER VIRPHY
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      XINDEX = VIRPHY(VIRNDX, NDX)
      IF (.NOT.( TYPE .EQ. 0 ))GOTO 23387
      VALUE(1) = IABS( BUF( NDX + 0 ) )
      GOTO 23388
23387 CONTINUE
      IF (.NOT.( TYPE .EQ. 1 ))GOTO 23389
      VALUE(1) = BUF( NDX + 1 )
      GOTO 23390
23389 CONTINUE
      IF (.NOT.( TYPE .EQ. 3 ))GOTO 23391
      IF (.NOT.( BUF( NDX + 0 ) .LT. 0 ))GOTO 23393
      VALUE(1) = 1
      GOTO 23394
23393 CONTINUE
      VALUE(1) = 0
23394 CONTINUE
      GOTO 23392
23391 CONTINUE
      IF (.NOT.( TYPE .EQ. 2 ))GOTO 23395
      VALUE(1) = BUF( NDX + 2 )
      VALUE(2) = BUF( NDX + 3 )
23395 CONTINUE
23392 CONTINUE
23390 CONTINUE
23388 CONTINUE
      RETURN
      END
      INTEGER FUNCTION GETFN( LIN, I, FILE)
      LOGICAL*1 FILE(512), LIN(512)
      INTEGER I, J, K
      COMMON /CFILE/ SAVFIL(40)
      LOGICAL*1 SAVFIL
      GETFN = -3
      IF (.NOT.( LIN(I) .EQ. 32 .OR. LIN(I) .EQ. 9 ))GOTO 23397
      J = I + 1
      CALL SKIPBL( LIN, J)
      K = 1 
23399 IF (.NOT.(LIN(J) .NE. 10 ))GOTO 23401
      FILE(K) = LIN(J)
      J = J + 1
23400 K = K + 1 
      GOTO 23399
23401 CONTINUE
      FILE(K) = 0
      IF (.NOT.( K .GT. 1 ))GOTO 23402
      GETFN = 0
23402 CONTINUE
      GOTO 23398
23397 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 10 .AND. SAVFIL(1) .NE. 0 ))GOTO 23404
      CALL STRCPY( SAVFIL, FILE)
      GETFN = 0
23404 CONTINUE
23398 CONTINUE
      RETURN
      END
      INTEGER FUNCTION GETIND(LINE)
      INTEGER J, K, LINE
      INTEGER NEXTLN, PREVLN
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      DATA OLDNDX / -3 /
      DATA OLDLIN / -2 /
      IF (.NOT.( OLDNDX .NE. -3 .AND. LINE .EQ. NEXTLN(OLDLIN) .AND. LIN
     *E .NE. 0 ))GOTO 23406
      CALL GETB( OLDNDX, 1, K)
      GOTO 23407
23406 CONTINUE
      IF (.NOT.( OLDNDX .NE. -3 .AND. LINE .EQ. OLDLIN ))GOTO 23408
      K = OLDNDX
      GOTO 23409
23408 CONTINUE
      IF (.NOT.( OLDNDX .NE. -3 .AND. LINE .EQ. PREVLN(OLDLIN) ))GOTO 23
     *410
      CALL GETB( OLDNDX, 0, K)
      GOTO 23411
23410 CONTINUE
      K = 1
      IF (.NOT.( LINE .LT. LASTLN / 2 ))GOTO 23412
      J = 0 
23414 IF (.NOT.(J .LT. LINE ))GOTO 23416
      CALL GETB( K, 1, K)
23415 J = J + 1 
      GOTO 23414
23416 CONTINUE
      GOTO 23413
23412 CONTINUE
      J = LASTLN 
23417 IF (.NOT.(J .GE. LINE ))GOTO 23419
      CALL GETB( K, 0, K)
23418 J = J - 1 
      GOTO 23417
23419 CONTINUE
23413 CONTINUE
23411 CONTINUE
23409 CONTINUE
23407 CONTINUE
      OLDLIN = LINE
      OLDNDX = K
      GETIND = K
      RETURN
      END
      INTEGER FUNCTION GETLST( LIN, I, STATUS)
      LOGICAL*1 LIN(512)
      INTEGER GETONE
      INTEGER I, NUM, STATUS
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      LINE2 = 0
      NLINES = 0 
23420 IF (.NOT.(GETONE( LIN, I, NUM, STATUS) .EQ. 0 ))GOTO 23422
      LINE1 = LINE2
      LINE2 = NUM
      NLINES = NLINES + 1
      IF (.NOT.( LIN(I) .NE. 44 .AND. LIN(I) .NE. 59 ))GOTO 23423
      GOTO 23422
23423 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 59 ))GOTO 23425
      CURLN = NUM
23425 CONTINUE
      I = I + 1
23421 GOTO 23420
23422 CONTINUE
      NLINES = MIN0( NLINES, 2)
      IF (.NOT.( NLINES .EQ. 0 ))GOTO 23427
      LINE2 = CURLN
23427 CONTINUE
      IF (.NOT.( NLINES .LE. 1 ))GOTO 23429
      LINE1 = LINE2
23429 CONTINUE
      IF (.NOT.( STATUS .NE. -3 ))GOTO 23431
      STATUS = 0
23431 CONTINUE
      GETLST=(STATUS)
      RETURN
      END
      INTEGER FUNCTION GETNUM( LIN, I, PNUM, STATUS)
      LOGICAL*1 LIN(512)
      INTEGER CTOI, INDEXC, LENGTH, OPTPAT, PTSCAN
      INTEGER I, J, PNUM, STATUS
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CPAT/ PAT(132)
      INTEGER PAT
      LOGICAL*1 DIGITS(11)
      LOGICAL*1 PNL(3)
      DATA DIGITS(1)/48/,DIGITS(2)/49/,DIGITS(3)/50/,DIGITS(4)/51/,DIGIT
     *S(5)/52/,DIGITS(6)/53/,DIGITS(7)/54/,DIGITS(8)/55/,DIGITS(9)/56/,D
     *IGITS(10)/57/,DIGITS(11)/0/
      DATA PNL(1)/112/,PNL(2)/10/,PNL(3)/0/
      GETNUM = 0
      IF (.NOT.( INDEXC( DIGITS, LIN(I) ) .GT. 0 ))GOTO 23433
      PNUM = CTOI( LIN, I)
      I = I - 1
      GOTO 23434
23433 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 46 ))GOTO 23435
      PNUM = CURLN
      GOTO 23436
23435 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 36 ))GOTO 23437
      PNUM = LASTLN
      GOTO 23438
23437 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 45 ))GOTO 23439
      PNUM = CURLN - 1
      GOTO 23440
23439 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 43 ))GOTO 23441
      PNUM = CURLN + 1
      GOTO 23442
23441 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 47 .OR. LIN(I) .EQ. 92 ))GOTO 23443
      IF (.NOT.( INDEXC( LIN( I + 1 ), LIN(I) ) .EQ. 0 ))GOTO 23445
      J = LENGTH(LIN)
      CALL CHCOPY( LIN(I), LIN, J)
      CALL STCOPY( PNL, 1, LIN, J)
23445 CONTINUE
      IF (.NOT.( OPTPAT( LIN, I) .EQ. -3 ))GOTO 23447
      GETNUM = -3
      GOTO 23448
23447 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 47 ))GOTO 23449
      GETNUM = PTSCAN( 43, PNUM)
      GOTO 23450
23449 CONTINUE
      GETNUM = PTSCAN( 45, PNUM)
23450 CONTINUE
23448 CONTINUE
      GOTO 23444
23443 CONTINUE
      GETNUM = -1
23444 CONTINUE
23442 CONTINUE
23440 CONTINUE
23438 CONTINUE
23436 CONTINUE
23434 CONTINUE
      IF (.NOT.( GETNUM .EQ. 0 ))GOTO 23451
      I = I + 1
23451 CONTINUE
      STATUS = GETNUM
      RETURN
      END
      INTEGER FUNCTION GETONE( LIN, I, NUM, STATUS)
      LOGICAL*1 LIN(512)
      INTEGER GETNUM
      INTEGER I, ISTART, MUL, NUM, PNUM, STATUS
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      ISTART = I
      NUM = 0
      CALL SKIPBL( LIN, I)
      IF (.NOT.( GETNUM( LIN, I, NUM, STATUS) .EQ. 0 ))GOTO 23453
23455 CONTINUE
      CALL SKIPBL( LIN, I)
      IF (.NOT.( LIN(I) .NE. 43 .AND. LIN(I) .NE. 45 ))GOTO 23458
      STATUS = -1
      GOTO 23457
23458 CONTINUE
      IF (.NOT.( LIN(I) .EQ. 43 ))GOTO 23460
      MUL = +1
      GOTO 23461
23460 CONTINUE
      MUL = -1
23461 CONTINUE
      I = I + 1
      CALL SKIPBL( LIN, I)
      IF (.NOT.( GETNUM( LIN, I, PNUM, STATUS) .EQ. 0 ))GOTO 23462
      NUM = NUM + MUL * PNUM
23462 CONTINUE
      IF (.NOT.( STATUS .EQ. -1 ))GOTO 23464
      STATUS = -3
23464 CONTINUE
23456 IF (.NOT.( STATUS .NE. 0 ))GOTO 23455
23457 CONTINUE
23453 CONTINUE
      IF (.NOT.( NUM .LT. 0 .OR. NUM .GT. LASTLN ))GOTO 23466
      STATUS = -3
23466 CONTINUE
      IF (.NOT.( STATUS .EQ. -3 ))GOTO 23468
      GETONE = -3
      GOTO 23469
23468 CONTINUE
      IF (.NOT.( I .LE. ISTART ))GOTO 23470
      GETONE = -1
      GOTO 23471
23470 CONTINUE
      GETONE = 0
23471 CONTINUE
23469 CONTINUE
      STATUS = GETONE
      RETURN
      END
      INTEGER FUNCTION GETRHS( LIN, I, SUB, GFLAG)
      LOGICAL*1 LIN(512), SUB(132)
      INTEGER INDEXC, LENGTH, MAKSUB
      INTEGER GFLAG, I, J
      LOGICAL*1 CLOWER
      LOGICAL*1 PNL(3)
      DATA PNL(1)/112/,PNL(2)/10/,PNL(3)/0/
      GETRHS = -3
      IF (.NOT.( LIN(I) .EQ. 0 ))GOTO 23472
      RETURN
23472 CONTINUE
      IF (.NOT.( LIN( I + 1 ) .EQ. 0 ))GOTO 23474
      RETURN
23474 CONTINUE
      IF (.NOT.( INDEXC( LIN( I + 1 ), LIN(I) ) .EQ. 0 ))GOTO 23476
      J = LENGTH(LIN)
      CALL CHCOPY( LIN(I), LIN, J)
      CALL STCOPY( PNL, 1, LIN, J)
23476 CONTINUE
      I = MAKSUB( LIN, I + 1, LIN(I), SUB)
      IF (.NOT.( I .EQ. -3 ))GOTO 23478
      RETURN
23478 CONTINUE
      IF (.NOT.( CLOWER( LIN( I + 1 ) ) .EQ. 103 ))GOTO 23480
      I = I + 1
      GFLAG = 1
      GOTO 23481
23480 CONTINUE
      GFLAG = 0
23481 CONTINUE
      GETRHS=(0)
      RETURN
      END
      INTEGER FUNCTION GETTXT(LINE)
      INTEGER GETIND
      INTEGER J
      INTEGER LOC(2)
      INTEGER LINE
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      COMMON /CSCRAT/ SCR, SCREND(2) , SCRFIL(40)
      INTEGER SCR
      INTEGER SCREND
      LOGICAL*1 SCRFIL
      LOGICAL*1 NULL(1)
      DATA NULL(1)/0/
      J = GETIND(LINE)
      IF (.NOT.( LINE .NE. 0 ))GOTO 23482
      CALL GETB( J, 2, LOC)
      CALL SEEK( LOC, SCR)
      CALL READFL( TXT, DUMMY, SCR)
      GOTO 23483
23482 CONTINUE
      CALL STRCPY( NULL, TXT)
23483 CONTINUE
      GETTXT=(J)
      RETURN
      END
      INTEGER FUNCTION GTFNDX(NEWIND)
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      IF (.NOT.( FREE .NE. 0 ))GOTO 23484
      NEWIND = FREE
      CALL GETB( FREE, 1, FREE)
      GOTO 23485
23484 CONTINUE
      IF (.NOT.( LASTBF + 4 .LE. 32008 ))GOTO 23486
      NEWIND = LASTBF
      LASTBF = LASTBF + 4
      GOTO 23487
23486 CONTINUE
      NEWIND = -3
23487 CONTINUE
23485 CONTINUE
      GTFNDX=(NEWIND)
      RETURN
      END
      SUBROUTINE INITED
      LOGICAL*1 NUM(2)
      INTEGER I, J, JUNK
      INTEGER ITOC
      COMMON / CTBUFS / EDTBUF(40, 3)
      LOGICAL*1 EDTBUF
      COMMON / CNOREG / NOREG
      INTEGER NOREG
      COMMON / CSTACK / LEVEL, VRBS(2), DESC(2)
      INTEGER LEVEL
      INTEGER VRBS
      INTEGER DESC
      LOGICAL*1 EDT(4)
      DATA EDT(1)/101/,EDT(2)/100/,EDT(3)/116/,EDT(4)/0/
      J = 1 
23488 IF (.NOT.(J .LE. 3 ))GOTO 23490
      I = J - 1
      JUNK = ITOC( I, NUM, 2)
      EDT(3) = NUM(1)
      CALL SCRATF( EDT, EDTBUF( 1, J) )
23489 J = J + 1 
      GOTO 23488
23490 CONTINUE
      NOREG = 0
      LEVEL = 1
      VRBS(1) = 0
      DESC(1) = 1
      CALL VIRINT
      RETURN
      END
      INTEGER FUNCTION INJECT(LIN)
      LOGICAL*1 LIN(512)
      INTEGER GETIND, MAKLIN, NEXTLN
      INTEGER I, K1, K2, K3
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      I = 1 
23491 IF (.NOT.(LIN(I) .NE. 0 ))GOTO 23493
      I = MAKLIN( LIN, I, K3)
      IF (.NOT.( I .EQ. -3 ))GOTO 23494
      INJECT=(-3)
      RETURN
23494 CONTINUE
      K1 = GETIND(CURLN)
      K2 = GETIND( NEXTLN(CURLN) )
      CALL RELINK( K1, K3, K3, K2)
      CALL RELINK( K3, K2, K1, K3)
      CURLN = CURLN + 1
      LASTLN = LASTLN + 1
23492 GOTO 23491
23493 CONTINUE
      INJECT=(0)
      RETURN
      END
      INTEGER FUNCTION INPLIN( LIN, CHN, NUM)
      LOGICAL*1 LIN(100), PSTR(9)
      INTEGER CHN, I, N, NUM
      INTEGER ITOC, PROMPT
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      LOGICAL*1 TAIL(3)
      DATA TAIL(1)/61/,TAIL(2)/62/,TAIL(3)/0/
      IF (.NOT.( NUMBER .EQ. 1 ))GOTO 23496
      N = ITOC( NUM, PSTR, 7)
      I = 6 
23498 IF (.NOT.(I .GT. 0 ))GOTO 23500
      IF (.NOT.(N .GT. 0))GOTO 23501
      PSTR(I) = PSTR(N)
      GOTO 23502
23501 CONTINUE
      PSTR(I) = 32
23502 CONTINUE
23499 I = I - 1
      N = N - 1
      GOTO 23498
23500 CONTINUE
      CALL SCOPY( TAIL, 1, PSTR, 7)
      GOTO 23497
23496 CONTINUE
      PSTR(1) = 0
23497 CONTINUE
      INPLIN = PROMPT( PSTR, LIN, CHN)
      RETURN
      END
      INTEGER FUNCTION KOPY(LINE3)
      INTEGER JUNK, LINE3, NLINE, OFFSET
      INTEGER GETTXT, INJECT
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      IF (.NOT.( LINE1 .LE. 0 ))GOTO 23503
      KOPY = -3
      GOTO 23504
23503 CONTINUE
      KOPY = 0
      CURLN = LINE3
      NLINE = LINE1 
23505 IF (.NOT.(NLINE .LE. LINE2 ))GOTO 23507
      IF (.NOT.( NLINE .GT. LINE3 ))GOTO 23508
      OFFSET = NLINE - LINE1
      GOTO 23509
23508 CONTINUE
      OFFSET = 0
23509 CONTINUE
      JUNK = GETTXT( NLINE + OFFSET )
      KOPY = INJECT(TXT)
      IF (.NOT.( KOPY .EQ. -3 ))GOTO 23510
      GOTO 23507
23510 CONTINUE
23506 NLINE = NLINE + 1 
      GOTO 23505
23507 CONTINUE
23504 CONTINUE
      RETURN
      END
      INTEGER FUNCTION LMOVE(LINE3)
      INTEGER GETIND, NEXTLN, PREVLN
      INTEGER DELTA, K0, K1, K2, K3, K4, K5, LINE3
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      IF (.NOT.( LINE1 .LE. 0 .OR. ( LINE1 .LE. LINE3 .AND. LINE3 .LE. L
     *INE2 ) ))GOTO 23512
      LMOVE = -3
      GOTO 23513
23512 CONTINUE
      K0 = GETIND( PREVLN(LINE1) )
      K3 = GETIND( NEXTLN(LINE2) )
      K1 = GETIND(LINE1)
      K2 = GETIND(LINE2)
      CALL RELINK( K0, K3, K0, K3)
      DELTA = LINE2 - LINE1 + 1
      LASTLN = LASTLN - DELTA
      IF (.NOT.( LINE3 .GT. LINE1 ))GOTO 23514
      CURLN = LINE3
      LINE3 = LINE3 - DELTA
      GOTO 23515
23514 CONTINUE
      CURLN = LINE3 + DELTA
23515 CONTINUE
      K4 = GETIND(LINE3)
      K5 = GETIND( NEXTLN(LINE3) )
      CALL RELINK( K4, K1, K2, K5)
      CALL RELINK( K2, K5, K4, K1)
      LASTLN = LASTLN + DELTA
      LMOVE = 0
23513 CONTINUE
      RETURN
      END
      INTEGER FUNCTION MAKLIN( LIN, I, NEWIND)
      LOGICAL*1 LIN(512)
      INTEGER ADDSET, GTFNDX, NOTE
      INTEGER I, J, JUNK, NEWIND, NEWPTR
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      INTEGER TXTEND
      COMMON /CSCRAT/ SCR, SCREND(2) , SCRFIL(40)
      INTEGER SCR
      INTEGER SCREND
      LOGICAL*1 SCRFIL
      MAKLIN = -3
      OLDNDX = -3
      IF (.NOT.( GTFNDX(NEWIND) .EQ. -3 ))GOTO 23516
      CALL REMARK( 39H? Line descriptor space limit exceeded. )
      RETURN
23516 CONTINUE
      TXTEND = 1
      J = I 
23518 IF (.NOT.(LIN(J) .NE. 0 ))GOTO 23520
      JUNK = ADDSET( LIN(J), TXT, TXTEND, 512)
      J = J + 1
      IF (.NOT.( LIN( J - 1 ) .EQ. 10 ))GOTO 23521
      GOTO 23520
23521 CONTINUE
23519 GOTO 23518
23520 CONTINUE
      IF (.NOT.( ADDSET( 0, TXT, TXTEND, 512) .EQ. 0 ))GOTO 23523
      CALL PTFNDX( NEWIND, NEWIND)
      RETURN
23523 CONTINUE
      CALL SETB( NEWIND, 2, SCREND)
      CALL SEEK( SCREND, SCR)
      CALL PUTLIN( TXT, SCR)
      JUNK = NOTE(SCREND, SCR)
      CALL SETB( NEWIND, 3, 0)
      MAKLIN=(J)
      RETURN
      END
      INTEGER FUNCTION MAKSUB( ARG, FROM, DELIM, SUB)
      LOGICAL*1 ESC
      LOGICAL*1 ARG(128), DELIM, SUB(132)
      INTEGER ADDSET, CTOI, TYPE
      INTEGER FROM, I, J, JUNK
      J = 1
      I = FROM 
23525 IF (.NOT.(ARG(I) .NE. DELIM .AND. ARG(I) .NE. 0 ))GOTO 23527
      IF (.NOT.( ARG(I) .EQ. 38 ))GOTO 23528
      JUNK = ADDSET( (-3), SUB, J, 132)
      GOTO 23529
23528 CONTINUE
      IF (.NOT.( ARG(I) .EQ. 36 .AND. TYPE( ARG( I + 1 ) ) .EQ. 2 ))GOTO
     * 23530
      I = I + 1
      N = CTOI( ARG, I)
      JUNK = ADDSET( (-4), SUB, J, 132)
      JUNK = ADDSET( N, SUB, J, 132)
      I = I - 1
      GOTO 23531
23530 CONTINUE
      IF (.NOT.( ARG(I) .EQ. 36 .AND. ( ARG(I+1) .EQ. 110 .OR. ARG(I+1) 
     *.EQ. 78 ) ))GOTO 23532
      I = I + 1
      JUNK = ADDSET( (-5), SUB, J, 132)
      GOTO 23533
23532 CONTINUE
      JUNK = ADDSET( ESC( ARG, I), SUB, J, 132)
23533 CONTINUE
23531 CONTINUE
23529 CONTINUE
23526 I = I + 1 
      GOTO 23525
23527 CONTINUE
      IF (.NOT.( ARG(I) .NE. DELIM ))GOTO 23534
      MAKSUB = -3
      GOTO 23535
23534 CONTINUE
      IF (.NOT.( ADDSET( 0, SUB, J, 132) .EQ. 0 ))GOTO 23536
      MAKSUB = -3
      GOTO 23537
23536 CONTINUE
      MAKSUB = I
23537 CONTINUE
23535 CONTINUE
      RETURN
      END
      SUBROUTINE MAPPHY(I)
      INTEGER I, N, J, PND, JUNK
      INTEGER NOTE
      INTEGER CREATE
      COMMON / CVIRT / VIRIND(126), PHYIND(126), DSKADR(126)
      INTEGER VIRIND
      INTEGER PHYIND
      INTEGER*4 DSKADR
      COMMON / CVFILE / VIRUNT, VIREND, VPFILE(40)
      INTEGER VIRUNT
      INTEGER*4 VIREND
      LOGICAL*1 VPFILE
      COMMON / CLRU / LRUP(8), MRUP(8), PFNP(8)
      INTEGER LRUP
      INTEGER MRUP
      INTEGER PFNP
      LOGICAL*1 VPF(4)
      DATA VPF(1)/118/,VPF(2)/112/,VPF(3)/102/,VPF(4)/0/
      IF (.NOT.(VIRUNT .EQ. -3))GOTO 23538
      CALL SCRATF(VPF, VPFILE)
      VIRUNT = CREATE(VPFILE, -3)
      IF (.NOT.(VIRUNT .EQ. -3))GOTO 23540
      CALL ERROR(24HCannot open paging file.)
23540 CONTINUE
      JUNK = NOTE(VIREND, VIRUNT)
23538 CONTINUE
      N = LRUP(1)
      J = PFNP(N)
      PND = IABS(PHYIND(J))
      CALL PAGOUT(J)
      PHYIND(I) = PND
      CALL PAGIN(I)
      PFNP(N) = I
      CALL MRUSET(N)
      RETURN
      END
      SUBROUTINE MRUSET(N)
      INTEGER N, I, J
      COMMON / CLRU / LRUP(8), MRUP(8), PFNP(8)
      INTEGER LRUP
      INTEGER MRUP
      INTEGER PFNP
      IF (.NOT.(N .NE. 1))GOTO 23542
      J = LRUP(N)
      I = MRUP(N)
      MRUP(J) = I
      LRUP(I) = J
      I = MRUP(1)
      MRUP(1) = N
      LRUP(I) = N
      LRUP(N) = 1
      MRUP(N) = I
23542 CONTINUE
      RETURN
      END
      INTEGER FUNCTION NEXTLN(LINE)
      INTEGER LINE
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      NEXTLN = LINE + 1
      IF (.NOT.( NEXTLN .GT. LASTLN ))GOTO 23544
      NEXTLN = 0
23544 CONTINUE
      RETURN
      END
      INTEGER FUNCTION OPTPAT( LIN, I)
      LOGICAL*1 LIN(512)
      INTEGER MAKPAT
      INTEGER I
      COMMON /CPAT/ PAT(132)
      INTEGER PAT
      IF (.NOT.( LIN(I) .EQ. 0 ))GOTO 23546
      I = -3
      GOTO 23547
23546 CONTINUE
      IF (.NOT.( LIN( I + 1 ) .EQ. 0 ))GOTO 23548
      I = -3
      GOTO 23549
23548 CONTINUE
      IF (.NOT.( LIN( I + 1 ) .EQ. LIN(I) ))GOTO 23550
      I = I + 1
      GOTO 23551
23550 CONTINUE
      I = MAKPAT( LIN, I + 1, LIN(I), PAT)
23551 CONTINUE
23549 CONTINUE
23547 CONTINUE
      IF (.NOT.( PAT(1) .EQ. 0 ))GOTO 23552
      I = -3
23552 CONTINUE
      IF (.NOT.( I .EQ. -3 ))GOTO 23554
      PAT(1) = 0
      OPTPAT = -3
      GOTO 23555
23554 CONTINUE
      OPTPAT = 0
23555 CONTINUE
      RETURN
      END
      SUBROUTINE PAGIN(I)
      INTEGER I, N, JUNK
      INTEGER READF, PTREQ
      COMMON / CVIRT / VIRIND(126), PHYIND(126), DSKADR(126)
      INTEGER VIRIND
      INTEGER PHYIND
      INTEGER*4 DSKADR
      COMMON / CVFILE / VIRUNT, VIREND, VPFILE(40)
      INTEGER VIRUNT
      INTEGER*4 VIREND
      LOGICAL*1 VPFILE
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      N = PHYIND(I)
      IF (.NOT.(PTREQ(DSKADR(I), 0) .EQ. 1))GOTO 23556
      JUNK = N + 256
23558 IF (.NOT.(N .LT. JUNK))GOTO 23560
      BUF(N) = 0
23559 N=N+1
      GOTO 23558
23560 CONTINUE
      GOTO 23557
23556 CONTINUE
      CALL SEEK(DSKADR(I), VIRUNT)
      JUNK = READF(BUF(N), 512, VIRUNT)
23557 CONTINUE
      RETURN
      END
      SUBROUTINE PAGOUT(J)
      INTEGER J, N, JUNK, RESET
      INTEGER WRITEF, PTREQ, NOTE
      COMMON / CVIRT / VIRIND(126), PHYIND(126), DSKADR(126)
      INTEGER VIRIND
      INTEGER PHYIND
      INTEGER*4 DSKADR
      COMMON / CVFILE / VIRUNT, VIREND, VPFILE(40)
      INTEGER VIRUNT
      INTEGER*4 VIREND
      LOGICAL*1 VPFILE
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      IF (.NOT.(PHYIND(J) .LT. 0))GOTO 23561
      N = IABS(PHYIND(J))
      IF (.NOT.(PTREQ(DSKADR(J), 0) .EQ. 1))GOTO 23563
      CALL PTRCPY(VIREND, DSKADR(J))
      RESET = 1
      GOTO 23564
23563 CONTINUE
      RESET = 0
23564 CONTINUE
      CALL SEEK(DSKADR(J), VIRUNT)
      JUNK = WRITEF(BUF(N), 512, VIRUNT)
      IF (.NOT.(RESET .EQ. 1))GOTO 23565
      JUNK = NOTE(VIREND, VIRUNT)
23565 CONTINUE
23561 CONTINUE
      PHYIND(J) = 0
      RETURN
      END
      SUBROUTINE PDIRTY(I)
      INTEGER I, N
      COMMON / CVIRT / VIRIND(126), PHYIND(126), DSKADR(126)
      INTEGER VIRIND
      INTEGER PHYIND
      INTEGER*4 DSKADR
      COMMON / CLRU / LRUP(8), MRUP(8), PFNP(8)
      INTEGER LRUP
      INTEGER MRUP
      INTEGER PFNP
      PHYIND(I) = -IABS(PHYIND(I))
      N=1
23567 IF (.NOT.(N .LE. 8))GOTO 23569
      IF (.NOT.(PFNP(N) .EQ. I))GOTO 23570
      GOTO 23569
23570 CONTINUE
23568 N=N+1
      GOTO 23567
23569 CONTINUE
      CALL MRUSET(N)
      RETURN
      END
      SUBROUTINE PERCEN
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      INTEGER CHRPER, LINPER
      LINPER = LASTBF / 320
      CALL PUTINT( LINPER, 2,2)
      CALL PUTLIN( 34H percent of line descriptors used., 2)
      CALL PUTCH(10,2)
      RETURN
      END
      INTEGER FUNCTION PREVLN(LINE)
      INTEGER LINE
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      PREVLN = LINE - 1
      IF (.NOT.( PREVLN .LT. 0 ))GOTO 23572
      PREVLN = LASTLN
23572 CONTINUE
      RETURN
      END
      SUBROUTINE PTFNDX( START, STOP)
      INTEGER START, STOP
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      CALL SETB( STOP, 1, FREE)
      FREE = START
      RETURN
      END
      SUBROUTINE PTLNUM( NUM, FD)
      INTEGER FD
      INTEGER NUM
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      LOGICAL*1 TAIL(3)
      DATA TAIL(1)/61/,TAIL(2)/62/,TAIL(3)/0/
      IF (.NOT.( NUMBER .EQ. 1 ))GOTO 23574
      CALL PUTINT( NUM, 6, FD)
      CALL PUTLIN( TAIL, FD)
23574 CONTINUE
      RETURN
      END
      INTEGER FUNCTION PTSCAN( WAY, NUM)
      INTEGER GETTXT, MATCH, NEXTLN, PREVLN
      INTEGER K, NUM, WAY
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CPAT/ PAT(132)
      INTEGER PAT
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      NUM = CURLN
23576 CONTINUE
      IF (.NOT.( WAY .EQ. 43 ))GOTO 23579
      NUM = NEXTLN(NUM)
      GOTO 23580
23579 CONTINUE
      NUM = PREVLN(NUM)
23580 CONTINUE
      K = GETTXT(NUM)
      IF (.NOT.( MATCH( TXT, PAT) .EQ. 1 ))GOTO 23581
      PTSCAN=(0)
      RETURN
23581 CONTINUE
23577 IF (.NOT.( NUM .EQ. CURLN ))GOTO 23576
23578 CONTINUE
      PTSCAN=(-3)
      RETURN
      END
      SUBROUTINE READFL( BUFFER, COUNT, INT)
      INTEGER COUNT, INT, JUNK
      INTEGER GETLIN
      LOGICAL*1 BUFFER(100)
      JUNK = GETLIN( BUFFER, INT)
      RETURN
      END
      SUBROUTINE RELINK( A, X, Y, B)
      INTEGER A, B, X, Y
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      OLDNDX = -3
      CALL SETB( X, 0, A)
      CALL SETB( Y, 1, B)
      IFMOD = 1
      RETURN
      END
      SUBROUTINE SETB( VIRNDX, TYPE, VALUE)
      INTEGER VIRNDX, TYPE, NDX
      INTEGER VALUE(2)
      INTEGER XINDEX
      INTEGER VIRPHY
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      XINDEX = VIRPHY(VIRNDX, NDX)
      IF (.NOT.( TYPE .EQ. 0 ))GOTO 23583
      IF (.NOT.( BUF( NDX + 0 ) .LT. 0 ))GOTO 23585
      BUF( NDX + 0 ) = -VALUE(1)
      GOTO 23586
23585 CONTINUE
      BUF( NDX + 0 ) = VALUE(1)
23586 CONTINUE
      GOTO 23584
23583 CONTINUE
      IF (.NOT.( TYPE .EQ. 1 ))GOTO 23587
      BUF( NDX + 1 ) = VALUE(1)
      GOTO 23588
23587 CONTINUE
      IF (.NOT.( TYPE .EQ. 3 ))GOTO 23589
      IF (.NOT.( VALUE(1) .EQ. 1 ))GOTO 23591
      BUF( NDX + 0 ) = -IABS( BUF( NDX + 0 ) )
      GOTO 23592
23591 CONTINUE
      BUF( NDX + 0 ) = IABS( BUF( NDX + 0 ) )
23592 CONTINUE
      GOTO 23590
23589 CONTINUE
      IF (.NOT.( TYPE .EQ. 2 ))GOTO 23593
      BUF( NDX + 2 ) = VALUE(1)
      BUF( NDX + 3 ) = VALUE(2)
23593 CONTINUE
23590 CONTINUE
23588 CONTINUE
23584 CONTINUE
      CALL PDIRTY(XINDEX)
      RETURN
      END
      SUBROUTINE SETBUF
      INTEGER K, JUNK
      INTEGER NOTE
      COMMON /CBUF/ BUF(2048), LASTBF, FREE
      INTEGER BUF, LASTBF, FREE
      COMMON /CDEL/ DELCNT, FSTDEL, LSTDEL
      INTEGER DELCNT
      INTEGER FSTDEL
      INTEGER LSTDEL
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      INTEGER CREATE
      COMMON /CSCRAT/ SCR, SCREND(2) , SCRFIL(40)
      INTEGER SCR
      INTEGER SCREND
      LOGICAL*1 SCRFIL
      LOGICAL*1 FIL(4)
      LOGICAL*1 NULL(1)
      DATA FIL(1)/101/,FIL(2)/100/,FIL(3)/115/,FIL(4)/0/
      DATA NULL(1)/0/
      CALL SCRATF( FIL, SCRFIL)
      SCR = CREATE( SCRFIL, 3)
      IF (.NOT.( SCR .EQ. -3 ))GOTO 23595
      CALL CANT(SCRFIL)
23595 CONTINUE
      JUNK = NOTE(SCREND, SCR)
      LASTBF = 1
      FREE = 0
      CALL MAKLIN( NULL, 1, K)
      CALL RELINK( K, K, K, K)
      CURLN = 0
      LASTLN = 0
      CURSAV = 0
      DELCNT = 0
      IFMOD = 0
      RETURN
      END
      INTEGER FUNCTION SUBST( SUB, GFLAG)
      LOGICAL*1 NEW(512), SUB(132)
      INTEGER ADDSET, AMATCH, CONCT, GETTXT, INJEXT
      INTEGER GFLAG, J, JUNK, K, LASTM, LINE, M, STATUS, SUBBED
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      COMMON /CPAT/ PAT(132)
      INTEGER PAT
      COMMON /CTXT/ TXT(512)
      LOGICAL*1 TXT
      SUBST = -3
      IF (.NOT.( LINE1 .LE. 0 ))GOTO 23597
      RETURN
23597 CONTINUE
      LINE = LINE1 
23599 IF (.NOT.(LINE .LE. LINE2 ))GOTO 23601
      J = 1
      SUBBED = 0
      JUNK = GETTXT(LINE)
      LASTM = 0
      K = 1 
23602 IF (.NOT.(TXT(K) .NE. 0 ))GOTO 23604
      IF (.NOT.( GFLAG .EQ. 1 .OR. SUBBED .EQ. 0 ))GOTO 23605
      M = AMATCH( TXT, K, PAT)
      GOTO 23606
23605 CONTINUE
      M = 0
23606 CONTINUE
      IF (.NOT.( M .GT. 0 .AND. LASTM .NE. M ))GOTO 23607
      SUBBED = 1
      CALL CATSUB( TXT, K, M, SUB, NEW, J, 512)
      LASTM = M
23607 CONTINUE
      IF (.NOT.( M .EQ. 0 .OR. M .EQ. K ))GOTO 23609
      JUNK = ADDSET( TXT(K), NEW, J, 512)
      K = K + 1
      GOTO 23610
23609 CONTINUE
      K = M
23610 CONTINUE
23603 GOTO 23602
23604 CONTINUE
      IF (.NOT.( SUBBED .EQ. 1 ))GOTO 23611
      IF (.NOT.( ADDSET( 0, NEW, J, 512) .EQ. 0 ))GOTO 23613
      SUBST = -3
      GOTO 23601
23613 CONTINUE
      SUBST = CONCT( LINE, NEW)
      IF (.NOT.( SUBST .EQ. -3 ))GOTO 23615
      GOTO 23601
23615 CONTINUE
      CALL DELETE( LINE, LINE, STATUS)
      SUBST = INJECT(NEW)
      IF (.NOT.( SUBST .EQ. -3 ))GOTO 23617
      GOTO 23601
23617 CONTINUE
      SUBST = 0
23611 CONTINUE
23600 LINE = LINE + 1 
      GOTO 23599
23601 CONTINUE
      RETURN
      END
      INTEGER FUNCTION TYPSET( LIN, I)
      INTEGER DOSPWN, DOWRIT, REMOVE
      INTEGER I, J, MODTMP, PRTTMP, STATUS, JUNK
      LOGICAL*1 LIN(100)
      COMMON / CSPWN / ARGARA(256), FILARA(40)
      LOGICAL*1 ARGARA
      LOGICAL*1 FILARA
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      LOGICAL*1 FMTSTR(8)
      LOGICAL*1 SEED(4)
      DATA FMTSTR(1)/102/,FMTSTR(2)/111/,FMTSTR(3)/114/,FMTSTR(4)/109/,F
     *MTSTR(5)/97/,FMTSTR(6)/116/,FMTSTR(7)/32/,FMTSTR(8)/0/
      DATA SEED(1)/102/,SEED(2)/109/,SEED(3)/116/,SEED(4)/0/
      MODTMP = IFMOD
      PRTTMP = PRINT
      PRINT = 0
      CALL SCRATF( SEED, FILARA)
      IF (.NOT.( DOWRIT( 1, LASTLN, FILARA) .NE. -3 ))GOTO 23619
      J = 1
      CALL STCOPY( FMTSTR, 1, ARGARA, J)
      CALL STCOPY( LIN, I, ARGARA, J)
      IF (.NOT.( ARGARA( J - 1 ) .EQ. 10 ))GOTO 23621
      J = J - 1
23621 CONTINUE
      CALL CHCOPY( 32, ARGARA, J)
      CALL STCOPY( FILARA, 1, ARGARA, J)
      J = 1
      STATUS = DOSPWN( ARGARA, J)
      GOTO 23620
23619 CONTINUE
      CALL REMARK( 28H? Can't create scratch file. )
      STATUS = -3
23620 CONTINUE
      JUNK = REMOVE(FILARA)
      IFMOD = MODTMP
      PRINT = PRTTMP
      RETURN
      END
      INTEGER FUNCTION UNDEL( LINE, GLOB)
      INTEGER GETIND, NEXTLN, PREVLN
      INTEGER GLOB, LINE
      INTEGER K1, K2, STATUS
      COMMON /CDEL/ DELCNT, FSTDEL, LSTDEL
      INTEGER DELCNT
      INTEGER FSTDEL
      INTEGER LSTDEL
      COMMON /CLINES/ LINE1, LINE2, NLINES, CURLN, LASTLN, PRINT, CURSAV
     *, OLDLIN, OLDNDX, IFMOD, NUMBER, AUTOIN
      INTEGER LINE1
      INTEGER LINE2
      INTEGER NLINES
      INTEGER CURLN
      INTEGER LASTLN
      INTEGER PRINT
      INTEGER CURSAV
      INTEGER OLDLIN
      INTEGER OLDNDX
      INTEGER IFMOD
      INTEGER NUMBER
      INTEGER AUTOIN
      IF (.NOT.( DELCNT .EQ. 0 .OR. GLOB .EQ. 1 ))GOTO 23623
      UNDEL=(-3)
      RETURN
23623 CONTINUE
      CURLN = LINE
      K1 = GETIND(CURLN)
      K2 = GETIND( NEXTLN(CURLN) )
      IF (.NOT.( CURLN .EQ. LASTLN ))GOTO 23625
      CURLN = CURLN + DELCNT
      GOTO 23626
23625 CONTINUE
      CURLN = NEXTLN(CURLN)
23626 CONTINUE
      LASTLN = LASTLN + DELCNT
      CALL RELINK( K1, FSTDEL, LSTDEL, K2)
      CALL RELINK( LSTDEL, K2, K1, FSTDEL)
      DELCNT = 0
      UNDEL=(0)
      RETURN
23624 CONTINUE
      END
      SUBROUTINE VIRINT
      INTEGER I, J
      COMMON / CVIRT / VIRIND(126), PHYIND(126), DSKADR(126)
      INTEGER VIRIND
      INTEGER PHYIND
      INTEGER*4 DSKADR
      COMMON / CVFILE / VIRUNT, VIREND, VPFILE(40)
      INTEGER VIRUNT
      INTEGER*4 VIREND
      LOGICAL*1 VPFILE
      COMMON / CLRU / LRUP(8), MRUP(8), PFNP(8)
      INTEGER LRUP
      INTEGER MRUP
      INTEGER PFNP
      I=1
      J=1
23627 IF (.NOT.(I .LE. 126))GOTO 23629
      VIRIND(I) = J
      CALL PTRCPY(0,DSKADR(I))
      IF (.NOT.(I .LE. 8))GOTO 23630
      PHYIND(I) = J
      GOTO 23631
23630 CONTINUE
      PHYIND(I) = 0
23631 CONTINUE
23628 I=I+1
      J=J+256
      GOTO 23627
23629 CONTINUE
      VIRUNT = -3
      I=1
23632 IF (.NOT.(I .LE. 8))GOTO 23634
      LRUP(I) = I - 1
      MRUP(I) = I + 1
      PFNP(I) = I
23633 I=I+1
      GOTO 23632
23634 CONTINUE
      LRUP(1) = 8
      MRUP(8) = 1
      RETURN
      END
      INTEGER FUNCTION VIRPHY(VIRTND, PHYSND)
      INTEGER VIRTND, PHYSND, I
      COMMON / CVIRT / VIRIND(126), PHYIND(126), DSKADR(126)
      INTEGER VIRIND
      INTEGER PHYIND
      INTEGER*4 DSKADR
      I = ((VIRTND - 1) / 256) + 1
      IF (.NOT.(PHYIND(I) .EQ. 0))GOTO 23635
      CALL MAPPHY(I)
23635 CONTINUE
      PHYSND = IABS(PHYIND(I)) + (VIRTND - VIRIND(I))
      VIRPHY=(I)
      RETURN
      END
