      SUBROUTINE MAIN
      INTEGER I, GETARG, J, INT, OPEN, K, OPENDR, DESC, GDRPRM
      LOGICAL*1 DOCDIR(40), ARG(40), BUF(40)
      INTEGER IMGET, IMPUT, JUNK
      INTEGER TABLE, IMINIT
      INTEGER MEM( 2000)
      LOGICAL*1 CMEM(4000)
      EQUIVALENCE (CMEM(1),MEM(1))
      COMMON/CDSMEM/MEM
      CALL QUERY(26Husage:  man [toolname] ...)
      TABLE = IMINIT(2000, 10)
      CALL GETDIR(6, 6, DOCDIR)
      I=1
23000 IF (.NOT.(GETARG(I, ARG, 40) .NE. -1))GOTO 23002
      JUNK = IMPUT(TABLE, ARG)
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(I .EQ. 1))GOTO 23003
      IF (.NOT.(OPENDR(DOCDIR, DESC) .EQ. -3))GOTO 23005
      CALL ERROR(45HCannot open directory of documentation files.)
23005 CONTINUE
23007 IF (.NOT.(GDRPRM(DESC, ARG) .NE. -1))GOTO 23008
      JUNK = IMPUT(TABLE, ARG)
      GOTO 23007
23008 CONTINUE
      CALL CLOSDR(DESC)
      CALL IMSORT(TABLE)
23003 CONTINUE
23009 IF (.NOT.(IMGET(TABLE, BUF) .NE. -1))GOTO 23010
      CALL CONCAT(DOCDIR, BUF, ARG)
      INT = OPEN(ARG, 1)
      IF (.NOT.(INT .EQ. -3))GOTO 23011
      CALL PUTLIN(BUF, 3)
      CALL REMARK(29H : no manual entry available.)
      GOTO 23012
23011 CONTINUE
      CALL FCOPY(INT, 2)
      CALL CLOSE(INT)
23012 CONTINUE
      GOTO 23009
23010 CONTINUE
      RETURN
      END
