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