      INTEGER FUNCTION SSPAWN(IMAGE, ARGS, PID, WAIT)
      LOGICAL*1 IMAGE(40), ARGS(256), PID(7), LOCAL(6), WAIT, MCRLIN(80)
     *, FILARG(40)
      REAL MCR
      INTEGER EQUAL, LENGTH, N, ERRSB(8)
      COMMON / CSPAWN / EFN, IFFORE, IFBACK, IFBAST, FOREPC(7), BACKPC(7
     *), TASKNM(7)
      INTEGER EFN
      INTEGER IFFORE
      INTEGER IFBACK
      INTEGER IFBAST
      LOGICAL*1 FOREPC
      LOGICAL*1 BACKPC
      LOGICAL*1 TASKNM
      COMMON / CRAWTT / IDS, PARAM(6), IOSB(4)
      INTEGER BCOUNT
      INTEGER IDS
      INTEGER PARAM
      LOGICAL*1 IOSB
      EQUIVALENCE (IOSB(3), BCOUNT)
      DATA LOCAL/108, 111, 99, 97, 108, 0/
      data mcr/6RMCR.../
      SSPAWN = -3
      CALL SCOPY(IMAGE, 1, MCRLIN, 1)
      CALL FOLD(MCRLIN)
      IF(.NOT.(EQUAL(MCRLIN, LOCAL) .EQ. 1))GOTO 23000
      CALL SCOPY(ARGS, 1, MCRLIN, 1)
      GOTO 23001
23000 CONTINUE
      CALL GENPNM(1, PID)
      IF(.NOT.(LENGTH(ARGS) .GT. 0))GOTO 23002
      CALL ASNLUN(7, 2HSR, 0, IDS)
      IF(.NOT.(IDS .LE. 0))GOTO 23004
      RETURN
23004 CONTINUE
      CALL GETADR(PARAM(1), ARGS)
      PARAM(2) = LENGTH(ARGS)
      CALL IRAD50(6, PID, PARAM(3))
      PARAM(5) = 0
      CALL WTQIO(256, 7, 7,, IOSB, PARAM, IDS)
      IF(.NOT.(IDS .LE. 0 .OR. IOSB(1) .LE. 0))GOTO 23006
      RETURN
23006 CONTINUE
23002 CONTINUE
      CALL GENRUN(IMAGE, PID, MCRLIN)
23001 CONTINUE
      N = LENGTH(MCRLIN)
      EFN = 7
      CALL EXTPNM(MCRLIN, FOREPC)
      CALL SCOPY(FOREPC, 1, PID, 1)
      IFFORE = 1
      CALL WTQIO(1024, 8)
      call spawn(mcr,,, efn,, errsb,, mcrlin, n, 0,, ids)
      IF(.NOT.(IDS .LE. 0))GOTO 23008
      IFFORE = 0
      SSPAWN = -3
      GOTO 23009
23008 CONTINUE
      CALL STOPFR(7, IDS)
      IFFORE = 0
      IF(.NOT.(ERRSB(1) .GT. 1))GOTO 23010
      SSPAWN = -3
      GOTO 23011
23010 CONTINUE
      SSPAWN = 0
23011 CONTINUE
23009 CONTINUE
      CALL WTQIO(768, 8)
      RETURN
      END
      INTEGER FUNCTION GETMSG(BUF)
      LOGICAL*1 BUF(100)
      INTEGER N, GETLIN, OLDMAK
      COMMON / CRAWTT / IDS, PARAM(6), IOSB(4)
      INTEGER BCOUNT
      INTEGER IDS
      INTEGER PARAM
      LOGICAL*1 IOSB
      EQUIVALENCE (IOSB(3), BCOUNT)
      CALL GETPNM(BUF)
      IF(.NOT.((BUF(1) .EQ. 36 .OR. BUF(1) .EQ. 46) .AND. BUF(2) .NE. BU
     *F(1)))GOTO 23012
      CALL ASNLUN(7, 2HSR, 0, IDS)
      IF(.NOT.(IDS .GT. 0))GOTO 23014
      CALL GETADR(PARAM(1), BUF)
      PARAM(2) = 256
      CALL WTQIO(512, 7, 7,, IOSB, PARAM, IDS)
      IF(.NOT.(IDS .GT. 0))GOTO 23016
      IDS = IOSB(1)
23016 CONTINUE
23014 CONTINUE
      IF(.NOT.(IDS .GT. 0))GOTO 23018
      N = BCOUNT + 1
      GOTO 23019
23018 CONTINUE
      BUF(1) = 32
      N = 2
23019 CONTINUE
      BUF(N) = 0
      GETMSG = N - 1
      GOTO 23013
23012 CONTINUE
      GETMSG = OLDMAK(BUF)
23013 CONTINUE
      RETURN
      END
