home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / CDOR0811.ZIP / SOURCE.ZIP / WILDDOWN.BAS < prev    next >
Encoding:
BASIC Source File  |  1993-07-07  |  9.8 KB  |  337 lines

  1. ' $INCLUDE: 'RBBS-VAR.MOD'
  2. ' $segment
  3. ' $dynamic
  4. ' * Originaly by Richard Todd (1:3612/299)
  5. ' * Changes for Mpl/Cdor by Peter Eibl and Dan Drinnon
  6. ' * Used with Permission
  7. ' *
  8.     TYPE RegTypeX
  9.        ax      AS INTEGER
  10.        bx      AS INTEGER
  11.        cx      AS INTEGER
  12.        dx      AS INTEGER
  13.        bp      AS INTEGER
  14.        si      AS INTEGER
  15.        di      AS INTEGER
  16.        flags   AS INTEGER
  17.        ds      AS INTEGER
  18.        es      AS INTEGER
  19.     END TYPE
  20.  
  21.     FUNCTION GetFirstMatchingFile$ (FileSpec$)
  22.  
  23.     DIM InRegs AS RegTypeX, OutRegs AS RegTypeX
  24. ' *
  25. ' * REM Get Disk Transfer Area (DTA) address
  26. ' *
  27.     InRegs.ax = &H2F00
  28.     CALL InterruptX(&H21, InRegs, OutRegs)
  29.     SegDTA% = OutRegs.es
  30.     OffDTA% = OutRegs.bx
  31. ' *
  32. ' * REM Now find first match
  33. ' *
  34.     NameFile$ = FileSpec$ + CHR$(0)
  35.     InRegs.ds = SSEG(NameFile$)
  36.     InRegs.dx = SADD(NameFile$)
  37.     InRegs.cx = 0
  38.     InRegs.ax = &H4E00
  39.     CALL InterruptX(&H21, InRegs, OutRegs)
  40.  
  41.     IF OutRegs.flags AND 1 THEN
  42.        GetFirstMatchingFile$ = ""
  43.        EXIT FUNCTION
  44.     END IF
  45.  
  46.     DEF SEG = SegDTA%
  47.     OffMatch% = OffDTA% + 29
  48.  
  49.     Match$ = ""
  50.     FOR i = 1 TO 13
  51.        C$ = CHR$(PEEK(OffMatch% + i))
  52.        IF C$ = CHR$(0) THEN
  53.           EXIT FOR
  54.        END IF
  55.        Match$ = Match$ + C$
  56.     NEXT i
  57.  
  58.     DEF SEG
  59.  
  60.     GetFirstMatchingFile$ = Match$
  61.  
  62.     END FUNCTION
  63. '
  64.     FUNCTION GetNextMatchingFile$
  65.  
  66.     DIM InRegs AS RegTypeX, OutRegs AS RegTypeX
  67. ' *
  68. ' * REM Get Disk Transfer Area (DTA) address
  69. ' *
  70.     InRegs.ax = &H2F00
  71.     CALL InterruptX(&H21, InRegs, OutRegs)
  72.     SegDTA% = OutRegs.es
  73.     OffDTA% = OutRegs.bx
  74. ' *
  75. ' * REM Now find next match
  76. ' *
  77.     InRegs.ax = &H4F00
  78.     CALL InterruptX(&H21, InRegs, OutRegs)
  79.  
  80.     IF OutRegs.flags AND 1 THEN
  81.        GetNextMatchingFile$ = ""
  82.        EXIT FUNCTION
  83.     END IF
  84.  
  85.     DEF SEG = SegDTA%
  86.     OffMatch% = OffDTA% + 29
  87.  
  88.     Match$ = ""
  89.     FOR i = 1 TO 13
  90.        C$ = CHR$(PEEK(OffMatch% + i))
  91.        IF C$ = CHR$(0) THEN
  92.           EXIT FOR
  93.        END IF
  94.        Match$ = Match$ + C$
  95.     NEXT i
  96.  
  97.     DEF SEG
  98.  
  99.     GetNextMatchingFile$ = Match$
  100.  
  101.     END FUNCTION
  102.  
  103. '
  104. ' ***  WILDDOWN  -  Find matches to input for download  ***
  105. '
  106. '
  107. ' * read in the config file
  108. '
  109.  
  110. 100 SUB WILDDOWN (ZFileName$, ZMarkedFiles$, ZFastFileList$, Found) STATIC
  111. '
  112.     REDIM ZOutTxt$(99)
  113.  
  114.     Found = ZFalse
  115.  
  116.     CALL QuickTPut (ZFG5$ + "Looking for Matches to " + _
  117.                 ZFGB$ + ZWasZ$ + ZFG5$ + SPACE$(1) + ZEmphasizeOn$ + _
  118.                 "(<CTRL-X> Aborts) " + ZEmphasizeOff$,0)
  119.     NumDots = 0
  120.     CfgFileName$ = LEFT$(ZFastFileList$, INSTR(ZFastFileList$, ".") -1) + ".CFG"
  121.     CLOSE 2
  122.     CALL OpenWork (2,CfgFileName$)
  123.     CALL ReadDir (2,1)
  124.     MaxFiles = VAL(ZOutTxt$)
  125. '
  126. ' * check for previously marked files
  127. '
  128.     IF LEN(ZMarkedFiles$) > MaxFiles * 13 THEN
  129.        CALL SkipLine (1)
  130.        CALL QuickTPut1(ZFGF$ + ZBG4$ + _
  131.                        "Too Many Files Already Marked!" + _
  132.                        ZEmphasizeOff$)
  133.        ZFileName$ = ""
  134.        EXIT SUB
  135.     END IF
  136. '
  137. ' * save the current list of marked files
  138. '
  139.    HoldMarkedFiles$ = ZMarkedFiles$
  140. '
  141. ' * read in the directories from the FIDX.CFG and check Security Level
  142. '
  143.     Index = 1
  144.     DO WHILE NOT EOF(2)
  145.        CALL ReadDir (2,1)
  146.        Level = INSTR(ZOutTxt$,",")
  147.        IF ZUserSecLevel >= VAL(LEFT$(ZOutTxt$,Level-1)) THEN
  148.           ZOutTxt$(Index) = RIGHT$(ZOutTxt$,LEN(ZOutTxt$)-Level)
  149.           Index = Index + 1
  150.        END IF
  151.     LOOP
  152.     CLOSE 2
  153. '
  154. ' * search in the Upload and Download Directories listed in the FIDX.CFG
  155. '
  156. 200 TotalMatch = 0
  157.     SearchDir = 1
  158.     ZMarkedFiles$ = ""
  159.     DO WHILE SearchDir < Index
  160.        GOSUB 700
  161.        IF KillSearch THEN GOTO 400
  162.        MatchFile$ = ""
  163.        FILESPEC$ = ZOutTxt$(SearchDir) + ZFileName$
  164.        IF SearchDir = 1 THEN
  165.           CALL SkipLine (1)
  166.           CALL QuickTPut (ZFG5$ + "Searching " + _
  167.                           ZFGB$ + "UPLOADS",0)
  168.        END IF
  169.        CALL MarkTime (NumDots)
  170.        MatchFile$ = GetFirstMatchingFile$(FILESPEC$)
  171.        IF MatchFile$ <> "" THEN
  172.           ZMarkedFiles$ = ZMarkedFiles$ + MatchFile$ + CHR$(13)
  173.           TotalMatch = TotalMatch + 1
  174.           MatchFile$ = GetNextMatchingFile$
  175.           DO WHILE MatchFile$ <> ""
  176.              CALL MarkTime (NumDots)
  177.              ZMarkedFiles$ = ZMarkedFiles$ + MatchFile$ + CHR$(13)
  178.              TotalMatch = TotalMatch + 1
  179.              MatchFile$ = GetNextMatchingFile$
  180.              IF TotalMatch => MaxFiles THEN
  181.                 CALL QuickTPut (ZBackSpace$,0)
  182.                 CALL SkipLine (1)
  183.                 CALL QuickTPut1(ZFGF$ + ZBG4$ + _
  184.                                 "Too Many Matching Files!" + _
  185.                                 ZEmphasizeOff$)
  186.                 ZFileName$ = ""
  187.                 GOTO 400
  188.              END IF
  189.           LOOP
  190.        END IF
  191.        SearchDir = SearchDir + 1
  192.     LOOP
  193.     CALL QuickTPut (ZBackSpace$,0)
  194. '
  195. ' * look in the FIDX.DEF
  196. '
  197. 300 IF NOT ZFastFileSearch THEN GOTO 400
  198.     CALL BreakFileName (ZFastFileList$, Drive$,Body$,Ext$,ZTrue)
  199.     TIdxLst$ = Drive$ + Body$ + ".LST"
  200.     CALL FindIt (TIdxLst$)
  201.     IF ZOK THEN
  202.        LineToRead = 1
  203.        CALL OpenWork (11,TIdxLst$)
  204.        IF ZErrCode <> 0 THEN
  205.           GOTO 400
  206.        END IF
  207. 305    CALL ReadParmsX (11,ZOutTxt$(),4,LineToRead)
  208.        IF ZErrCode <> 0 AND ZOutTxt$(1) = "" THEN
  209.           CLOSE 11
  210.           GOTO 400
  211.        END IF
  212.        LineToRead = LineToRead + 1
  213.        TFastFileList$ = ZOutTxt$(1)
  214.        CALL BreakFileName (ZOutTxt$(3),Drive$,Body$,Ext$,ZTrue)
  215.        CALL SkipLine (1)
  216.        CALL QuickTPut (ZFG5$ + "Searching " + ZFGB$ + _
  217.                        UCASE$(Body$) + SPACE$(2),0)
  218.        GOSUB 310
  219.        ZOutTxt$(1) = ""
  220.        GOTO 305
  221.     ELSE
  222.        TFastFileList$ = ZFastFileList$
  223.        GOSUB 310
  224.        GOTO 400
  225.     END IF
  226. 310 FSize = 21
  227.     CALL OpenRSeq (2,TFastFileList$,HighRec,WasX,21)
  228.     FIELD #2, 12 AS SearchFile$, _
  229.                4 AS SearchPath$, _
  230.                3 AS SearchDate$, _
  231.                2 AS SearchCrLf$
  232.     GET 2,1
  233.     IF SearchCrLf$ <> ZCRLf$ THEN
  234.        FSize = 18
  235.        CALL OpenRSeq (2,TFastFileList$,HighRec,WasX,18)
  236.        FIELD #2, 12 AS SearchFile$, _
  237.                   4 AS SearchPath$, _
  238.                   2 AS SearchCrLf$
  239.     END IF
  240. '
  241. ' * Set the LowRec value to 1 before checking for the tabs file low value.
  242. '
  243.     LowRec = 1                                                       ' DGS050401/DS
  244.  
  245. '
  246. ' * See if the Tabs File exists by checking for the proper size.
  247. ' * The file ZFastTabs$ is created in line 108 of RBBS-PC.
  248. '
  249.     IF LEN(ZFastTabs$) < 72 THEN _                                   ' DGS050401/DS
  250.        GOTO 350                                                      ' DGS050401/DS
  251.  
  252. '
  253. ' * Now check to see if the first letter is not a wildcard, to make
  254. ' * the searching of the FIDX file by the first letter, instead of
  255. ' * a sequential search (AAARRRRGGGGHHHHHH!!!!).  Most of this code
  256. ' * was taken from SUB5 witH variable names and some logic changed
  257. ' * to work in this sub.
  258. '
  259.     FirstLetter$ = LEFT$(ZFileName$,1)                               ' DGS050401/DS
  260.     FirstLet = INSTR("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*?",FirstLetter$) ' DGS050401/DS
  261.     IF FirstLet < 37 THEN                                            ' DGS050401/DS
  262.        IF FirstLet = 0 THEN                                          ' DGS050401/DS
  263.           LowRec = 1                                                 ' DGS050401/DS
  264.        ELSE                                                          ' DGS050401/DS
  265.           LowRec = CVI(MID$(ZFastTabs$,1+2*(FirstLet-1),2))          ' DGS050401/DS
  266.        END IF                                                        ' DGS050401/DS
  267.        IF FirstLet < 36 THEN _                                       ' DGS050401/DS
  268.           HighRec = CVI(MID$(ZFastTabs$,1+2*FirstLet,2))             ' DGS050401/DS
  269.     END IF                                                           ' DGS050401/DS
  270. 350 FOR Count = LowRec TO HighRec                                    ' DGS050401/DS
  271.        GET 2, Count
  272.        GOSUB 700
  273.        IF KillSearch THEN EXIT FOR
  274.        CALL MarkTime (NumDots)
  275.        FileName$ = SearchFile$
  276.        CALL Trim (FileName$)
  277.        CALL WildFile (ZFileName$,FileName$,DoesMatch)
  278.        IF DoesMatch THEN
  279.              ZMarkedFiles$ = ZMarkedFiles$ + Filename$ + CHR$(13)
  280.              TotalMatch = TotalMatch + 1
  281.        END IF
  282.        IF TotalMatch => MaxFiles THEN
  283.           CALL QuickTPut (ZBackSpace$,0)
  284.           CALL SkipLine (1)
  285.           CALL QuickTPut1(ZFGF$ + ZBG4$ + _
  286.                        "Too Many Matches!" + _
  287.                        ZEmphasizeOff$)
  288.           EXIT FOR
  289.        END IF
  290.     NEXT Count
  291.     RETURN
  292. 400 CLOSE 2
  293.     CALL QuickTPut (ZBackSpace$,0)
  294. '
  295. ' * display number of matches found and end sub
  296. '
  297. 600 ZFileName$ = ""
  298.     CALL OpenWorkA (2,ZNodeWorkDrvPath$+"WILDDOWN.DEF")
  299.     CALL PrintWorkA (2,ZMarkedFiles$)
  300.     CLOSE #2
  301.     CALL SkipLine (1)
  302.     CALL QuickTput1 (ZFGB$ + STR$(TotalMatch) + _
  303.                      ZFG2$ + " Matches Found" + ZEmphasizeOff$)
  304.  
  305.     IF ZMarkedFIles$ <> "" THEN Found = ZTrue
  306.  
  307.     ZMarkedFiles$ = HoldMarkedFiles$
  308.     EXIT SUB
  309. '
  310. ' * routine to find user break
  311. '
  312. 700 CALL FindFKey
  313.     KillSearch = ZFalse
  314.     IF ZKeyPressed$ = CHR$(24) THEN
  315.        KillSearch = ZTrue
  316.     END IF
  317.     IF ZLocalUser THEN
  318.        RETURN
  319.     END IF
  320.     IF ZCommPortStack$ <> "" THEN
  321.        IF LEFT$(ZCommPortStack$,LEN(ZCommPortStack$)-1) = CHR$(24) THEN
  322.           KillSearch = ZTrue
  323.        END IF
  324.     END IF
  325.     CALL EofComm (Char)
  326.     IF Char <> -1 THEN
  327.        CALL GetCom (WasX$)
  328.        IF WasX$ = CHR$(24) THEN
  329.           KillSearch = ZTrue
  330.        END IF
  331.     END IF
  332.     CALL FlushCom (ZCommPortStack$)
  333.     RETURN
  334.  
  335.     END SUB
  336.  
  337.