      SUBROUTINE MAIN
      LOGICAL*1 LIN(400), BUF(200), OBUF(500)
      INTEGER BP, OBP, I, J, JUNK, NFILES, LEN, FD(12)
      INTEGER OPEN, GETARG, GETLIN, ESC, ADDSET
      BP = 1
      NFILES = 0
      I = 1
23000 IF(.NOT.(GETARG(I, LIN, 400) .NE. -1))GOTO 23002
      IF(.NOT.(LIN(1) .EQ. 63 .AND. LIN(2) .EQ. 0))GOTO 23003
      CALL ERROR (31Husage:  lam [-sstring: | file].)
23003 CONTINUE
      IF(.NOT.(I .GT. 12))GOTO 23005
      CALL ERROR(19Htoo many arguments.)
23005 CONTINUE
      IF(.NOT.(LIN(1) .EQ. 45 .AND. LIN(2) .NE. 0))GOTO 23007
      FD(I) = -BP
      J = 2
23009 IF(.NOT.(LIN(J) .NE. 0))GOTO 23011
      JUNK = ADDSET(ESC(LIN, J), BUF, BP, 200)
23010 J = J + 1
      GOTO 23009
23011 CONTINUE
      IF(.NOT.(ADDSET(0, BUF, BP, 200) .EQ. 0))GOTO 23012
      CALL ERROR(17Htoo many strings.)
23012 CONTINUE
      GOTO 23008
23007 CONTINUE
      NFILES = NFILES + 1
      IF(.NOT.(LIN(1) .EQ. 45))GOTO 23014
      FD(I) = 1
      GOTO 23015
23014 CONTINUE
      FD(I) = OPEN(LIN, 1)
23015 CONTINUE
      IF(.NOT.(FD(I) .EQ. -3))GOTO 23016
      CALL CANT(LIN)
23016 CONTINUE
23008 CONTINUE
23001 I = I + 1
      GOTO 23000
23002 CONTINUE
      IF(.NOT.(NFILES .EQ. 0))GOTO 23018
      NFILES = 1
      FD(I) = 1
      GOTO 23019
23018 CONTINUE
      I = I - 1
23019 CONTINUE
      N = I
      OBP = 1
23020 IF(.NOT.(NFILES .GT. 0))GOTO 23022
      I = 1
23023 IF(.NOT.(I .LE. N))GOTO 23025
      IF(.NOT.(FD(I) .LT. 0 ))GOTO 23026
      J = -FD(I)
23028 IF(.NOT.(BUF(J) .NE. 0))GOTO 23030
      IF(.NOT.( ADDSET(BUF(J), OBUF, OBP, 500) .EQ. 0))GOTO 23031
      CALL ERROR (23Houtput buffer exceeded.)
23031 CONTINUE
23029 J = J + 1
      GOTO 23028
23030 CONTINUE
      GOTO 23027
23026 CONTINUE
      IF(.NOT.(FD(I) .NE. -1))GOTO 23033
      LEN = GETLIN(LIN, FD(I))
      IF(.NOT.(LEN .EQ. -1))GOTO 23035
      NFILES = NFILES - 1
      IF(.NOT.(FD(I) .NE. 1))GOTO 23037
      CALL CLOSE(FD(I))
23037 CONTINUE
      FD(I) = -1
      GOTO 23036
23035 CONTINUE
      J = 1
23039 IF(.NOT.(J .LT. LEN))GOTO 23041
      IF(.NOT.( ADDSET(LIN(J), OBUF, OBP, 500) .EQ. 0))GOTO 23042
      CALL ERROR (23Houtput buffer exceeded.)
23042 CONTINUE
23040 J = J + 1
      GOTO 23039
23041 CONTINUE
23036 CONTINUE
23033 CONTINUE
23027 CONTINUE
23024 I = I + 1
      GOTO 23023
23025 CONTINUE
      IF(.NOT.(NFILES .GT. 0))GOTO 23044
      J = 1
23046 IF(.NOT.(J .LT. OBP))GOTO 23048
      CALL PUTCH(OBUF(J), 2)
23047 J = J + 1
      GOTO 23046
23048 CONTINUE
      CALL PUTCH(10, 2)
23044 CONTINUE
23021 OBP = 1
      GOTO 23020
23022 CONTINUE
      RETURN
      END
