      SUBROUTINE MAIN
      INTEGER DESC, N, J, I, DDESC, PAT(132)
      INTEGER GETARG, GETPAT, OPENDR, GDRPRM, INDEXS, MATCH
      LOGICAL*1 TEMP(40), FILE(40), DEVICE(40)
      LOGICAL*1 USESTR(29)
      LOGICAL*1 SYSDEV(5)
      LOGICAL*1 ZZ(6)
      LOGICAL*1 DOTDIR(5)
      DATA USESTR(1)/117/,USESTR(2)/115/,USESTR(3)/97/,USESTR(4)/103/,US
     *ESTR(5)/101/,USESTR(6)/58/,USESTR(7)/32/,USESTR(8)/32/,USESTR(9)/1
     *19/,USESTR(10)/104/,USESTR(11)/101/,USESTR(12)/114/,USESTR(13)/101
     */,USESTR(14)/105/,USESTR(15)/115/,USESTR(16)/32/,USESTR(17)/112/,U
     *SESTR(18)/97/,USESTR(19)/116/,USESTR(20)/32/,USESTR(21)/91/,USESTR
     *(22)/97/,USESTR(23)/110/,USESTR(24)/99/,USESTR(25)/104/,USESTR(26)
     */111/,USESTR(27)/114/,USESTR(28)/93/,USESTR(29)/0/
      DATA SYSDEV(1)/47/,SYSDEV(2)/115/,SYSDEV(3)/121/,SYSDEV(4)/48/,SYS
     *DEV(5)/0/
      DATA ZZ(1)/91/,ZZ(2)/48/,ZZ(3)/44/,ZZ(4)/48/,ZZ(5)/93/,ZZ(6)/0/
      DATA DOTDIR(1)/46/,DOTDIR(2)/100/,DOTDIR(3)/105/,DOTDIR(4)/114/,DO
     *TDIR(5)/0/
      CALL QUERY(USESTR)
      IF (.NOT.(GETARG(1, TEMP, 40) .EQ. -1))GOTO 23000
      CALL ERROR(USESTR)
23000 CONTINUE
      CALL FOLD(TEMP)
      IF (.NOT.(GETPAT(TEMP, PAT) .EQ. -3))GOTO 23002
      CALL ERROR(15Hillegal pattern)
23002 CONTINUE
      IF (.NOT.(GETARG(2, TEMP, 40) .EQ. -1))GOTO 23004
      CALL GWDIR(TEMP, 6)
23004 CONTINUE
      CALL FXLATE(TEMP,6, DEVICE)
      IF (.NOT.(INDEXC(DEVICE, 91) .EQ. 0))GOTO 23006
      DOALL = 1
      CALL CONCAT(DEVICE, ZZ, TEMP)
      GOTO 23007
23006 CONTINUE
      DOALL = 0
      CALL STRCPY(DEVICE, TEMP)
23007 CONTINUE
      CALL MKPATH(TEMP, FILE)
      IF (.NOT.(OPENDR(FILE, DESC) .NE. 0))GOTO 23008
      CALL CANT(FILE)
23008 CONTINUE
      IF (.NOT.(DOALL .EQ. 0))GOTO 23010
      CALL DSPFIL(DESC, FILE, PAT)
      GOTO 23011
23010 CONTINUE
23012 IF (.NOT.(GDRPRM(DESC, TEMP) .NE. -1))GOTO 23013
      N = INDEXS(TEMP, DOTDIR)
      IF (.NOT.(N .GT. 0))GOTO 23014
      J = 1
      CALL STCOPY(DEVICE, 1, FILE, J)
      CALL CHCOPY(91, FILE, J)
      I=1
23016 IF (.NOT.(I .LE. 3))GOTO 23018
      CALL CHCOPY(TEMP(I), FILE, J)
23017 I=I+1
      GOTO 23016
23018 CONTINUE
      CALL CHCOPY(44, FILE, J)
      I=4
23019 IF (.NOT.(I .LE. 6))GOTO 23021
      CALL CHCOPY(TEMP(I), FILE, J)
23020 I=I+1
      GOTO 23019
23021 CONTINUE
      CALL CHCOPY(93, FILE, J)
      CALL MKPATH(FILE, TEMP)
      IF (.NOT.(OPENDR(TEMP, DDESC) .EQ. -3))GOTO 23022
      CALL PUTLIN(TEMP, 3)
      CALL REMARK(24H: cannot open directory.)
      GOTO 23023
23022 CONTINUE
      CALL DSPFIL(DDESC, TEMP, PAT)
23023 CONTINUE
23014 CONTINUE
      GOTO 23012
23013 CONTINUE
      CALL CLOSDR(DESC)
23011 CONTINUE
      RETURN
      END
      SUBROUTINE DSPFIL(DESC, DIRECT, PAT)
      INTEGER DESC, PAT(132)
      LOGICAL*1 DIRECT(100), ENTRY(40)
      INTEGER GDRPRM, MATCH
23024 IF (.NOT.(GDRPRM(DESC, ENTRY) .NE. -1))GOTO 23025
      IF (.NOT.(MATCH(ENTRY, PAT) .EQ. 1))GOTO 23026
      CALL PUTLIN(DIRECT, 2)
      CALL PUTCH(47, 2)
      CALL PUTLIN(ENTRY, 2)
      CALL PUTCH(10, 2)
23026 CONTINUE
      GOTO 23024
23025 CONTINUE
      CALL CLOSDR(DESC)
      RETURN
      END
