home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk1 / seek.fr_ / seek.bin
Text File  |  1993-04-28  |  9KB  |  281 lines

  1. VERSION 2.00
  2. Begin Form WinSeek 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Seek"
  6.    ForeColor       =   &H00000080&
  7.    Height          =   4440
  8.    Left            =   2190
  9.    MaxButton       =   0   'False
  10.    MinButton       =   0   'False
  11.    ScaleHeight     =   4035
  12.    ScaleWidth      =   3690
  13.    Top             =   1575
  14.    Width           =   3810
  15.    Begin PictureBox Picture2 
  16.       BorderStyle     =   0  'None
  17.       Height          =   2895
  18.       Left            =   720
  19.       ScaleHeight     =   2895
  20.       ScaleWidth      =   3855
  21.       TabIndex        =   8
  22.       Top             =   1080
  23.       Visible         =   0   'False
  24.       Width           =   3855
  25.       Begin ListBox lstFoundFiles 
  26.          Height          =   2370
  27.          Left            =   120
  28.          TabIndex        =   11
  29.          Top             =   480
  30.          Width           =   3375
  31.       End
  32.       Begin Label lblCount 
  33.          Caption         =   "0"
  34.          Height          =   255
  35.          Left            =   1200
  36.          TabIndex        =   10
  37.          Top             =   120
  38.          Width           =   1095
  39.       End
  40.       Begin Label lblfound 
  41.          Caption         =   "&Files Found:"
  42.          Height          =   255
  43.          Left            =   120
  44.          TabIndex        =   9
  45.          Top             =   120
  46.          Width           =   1095
  47.       End
  48.    End
  49.    Begin PictureBox Picture1 
  50.       BorderStyle     =   0  'None
  51.       Height          =   2895
  52.       Left            =   0
  53.       ScaleHeight     =   2895
  54.       ScaleWidth      =   3735
  55.       TabIndex        =   2
  56.       Top             =   120
  57.       Width           =   3735
  58.       Begin DriveListBox drvList 
  59.          Height          =   1530
  60.          Left            =   2040
  61.          TabIndex        =   7
  62.          Top             =   480
  63.          Width           =   1575
  64.       End
  65.       Begin DirListBox dirList 
  66.          Height          =   1695
  67.          Left            =   2040
  68.          TabIndex        =   6
  69.          Top             =   960
  70.          Width           =   1575
  71.       End
  72.       Begin FileListBox filList 
  73.          Height          =   2175
  74.          Left            =   120
  75.          TabIndex        =   5
  76.          Top             =   480
  77.          Width           =   1815
  78.       End
  79.       Begin TextBox txtSearchSpec 
  80.          Height          =   285
  81.          Left            =   2040
  82.          TabIndex        =   4
  83.          Text            =   "*.*"
  84.          Top             =   120
  85.          Width           =   1575
  86.       End
  87.       Begin Label lblCriteria 
  88.          Caption         =   "Search &Criteria:"
  89.          Height          =   255
  90.          Left            =   600
  91.          TabIndex        =   3
  92.          Top             =   120
  93.          Width           =   1335
  94.       End
  95.    End
  96.    Begin CommandButton cmdSearch 
  97.       BackColor       =   &H00C0C0C0&
  98.       Caption         =   "&Search"
  99.       Default         =   -1  'True
  100.       Height          =   720
  101.       Left            =   480
  102.       TabIndex        =   0
  103.       Top             =   3000
  104.       Width           =   1200
  105.    End
  106.    Begin CommandButton cmdExit 
  107.       BackColor       =   &H00C0C0C0&
  108.       Caption         =   "E&xit"
  109.       Height          =   720
  110.       Left            =   2040
  111.       TabIndex        =   1
  112.       Top             =   3000
  113.       Width           =   1200
  114.    End
  115. End
  116. Option Explicit
  117. Dim SearchFlag As Integer    ' Used as flag for cancelling, etc.
  118.  
  119. Sub cmdExit_Click ()
  120.   If cmdExit.Caption = "E&xit" Then
  121.     End
  122.   Else                ' If Cancel, just end Search.
  123.     SearchFlag = False
  124.   End If
  125. End Sub
  126.  
  127. Sub cmdSearch_Click ()
  128. ' Initialize for search, then call DirDiver to perform recursive search.
  129. Dim FirstPath As String, DirCount As Integer, NumFiles As Integer
  130. Dim result As Integer
  131.   ' Check what the user did last:
  132.   If cmdSearch.Caption = "&Reset" Then  ' If just a reset,
  133.     ResetSearch                         ' initialize and exit.
  134.     txtSearchSpec.SetFocus
  135.     Exit Sub
  136.   End If
  137.  
  138.   ' Update dirList.Path if it is different from the currently
  139.   ' selected directory, otherwise perform the search.
  140.   If dirList.Path <> dirList.List(dirList.ListIndex) Then
  141.      dirList.Path = dirList.List(dirList.ListIndex)
  142.      Exit Sub         ' Exit so user can take a look before searching.
  143.   End If
  144.  
  145.   ' Continue with the search.
  146.   Picture2.Move 0, 0
  147.   Picture1.Visible = False
  148.   Picture2.Visible = True
  149.  
  150.   cmdExit.Caption = "Cancel"
  151.  
  152.   filList.Pattern = txtSearchSpec.Text
  153.   FirstPath = dirList.Path
  154.   DirCount = dirList.ListCount
  155.  
  156.   'Start recursive direcory search.
  157.   NumFiles = 0                       ' Reset global foundfiles indicator.
  158.   result = DirDiver(FirstPath, DirCount, "")
  159.   filList.Path = dirList.Path
  160.   cmdSearch.Caption = "&Reset"
  161.   cmdSearch.SetFocus
  162.   cmdExit.Caption = "E&xit"
  163.  
  164. End Sub
  165.  
  166. Function DirDiver (NewPath As String, DirCount As Integer, BackUp As String) As Integer
  167. '  Recursively search directories from NewPath down...
  168. '     NewPath is searched on this recursion.
  169. '     BackUp is origin of this recursion.
  170. '     DirCount is number of subdirectories in this directory.
  171. Static FirstErr As Integer
  172. Dim DirsToPeek As Integer, AbandonSearch As Integer, ind As Integer
  173. Dim OldPath As String, ThePath As String, entry As String
  174. Dim retval As Integer
  175.   SearchFlag = True             ' Set flag so user can interrupt.
  176.   DirDiver = False              ' Set to TRUE if there is an error.
  177.   retval = DoEvents()           ' check for events (i.e. user Cancels).
  178.   If SearchFlag = False Then
  179.     DirDiver = True
  180.     Exit Function
  181.   End If
  182.   On Local Error GoTo DirDriverHandler
  183.   DirsToPeek = dirList.ListCount            ' How many directories below this?
  184.   Do While DirsToPeek > 0 And SearchFlag = True
  185.     OldPath = dirList.Path                  ' Save old path for next recursion.
  186.     dirList.Path = NewPath
  187.     If dirList.ListCount > 0 Then
  188.     ' Get to the node bottom.
  189.       dirList.Path = dirList.List(DirsToPeek - 1)
  190.       AbandonSearch = DirDiver((dirList.Path), DirCount%, OldPath)
  191.     End If
  192.     ' Go up 1 level in directories.
  193.     DirsToPeek = DirsToPeek - 1
  194.     If AbandonSearch = True Then Exit Function
  195.   Loop
  196.   ' Call function to enumerate files.
  197.   If filList.ListCount Then
  198.     If Len(dirList.Path) <= 3 Then
  199.     ThePath = dirList.Path         ' If at root level, leave as is...
  200.     Else
  201.     ThePath = dirList.Path + "\"   ' otherwise put "\" before file name.
  202.     End If
  203.     For ind = 0 To filList.ListCount - 1        ' Add conforming files in
  204.     entry = ThePath + filList.List(ind)     ' this directory to listbox.
  205.     lstFoundFiles.AddItem entry
  206.     lblCount.Caption = Str$(Val(lblCount.Caption) + 1)
  207.     Next ind
  208.   End If
  209.   If BackUp <> "" Then         ' If there is a superior
  210.       dirList.Path = BackUp    ' directory, move to it.
  211.   End If
  212.   Exit Function
  213. DirDriverHandler:
  214.   If Err = 7 Then         ' If Out of Memory, assume listbox just got full.
  215.     DirDiver = True       ' Create Msg$ and set return value AbandonSearch.
  216.     MsgBox "You've filled the listbox. Search being abandoned..."
  217.     Exit Function         ' Note that EXIT procedure resets ERR to 0.
  218.   Else                    ' Otherwise display error message and quit.
  219.     MsgBox Error
  220.     End
  221.   End If
  222. End Function
  223.  
  224. Sub DirList_Change ()
  225.     ' Update File listbox to sync with Dir listbox.
  226.     filList.Path = dirList.Path
  227. End Sub
  228.  
  229. Sub DirList_LostFocus ()
  230.     dirList.Path = dirList.List(dirList.ListIndex)
  231. End Sub
  232.  
  233. Sub DrvList_Change ()
  234.     On Error GoTo DriveHandler
  235.     dirList.Path = drvList.Drive
  236.     Exit Sub
  237.  
  238. DriveHandler:
  239.     drvList.Drive = dirList.Path
  240.     Exit Sub
  241. End Sub
  242.  
  243. Sub Form_Load ()
  244.     Picture2.Move 0, 0
  245.     Picture2.Width = WinSeek.ScaleWidth
  246.     Picture2.BackColor = WinSeek.BackColor
  247.     lblCount.BackColor = WinSeek.BackColor
  248.     lblCriteria.BackColor = WinSeek.BackColor
  249.     lblFound.BackColor = WinSeek.BackColor
  250.     Picture1.Move 0, 0
  251.     Picture1.Width = WinSeek.ScaleWidth
  252.     Picture1.BackColor = WinSeek.BackColor
  253. End Sub
  254.  
  255. Sub Form_Unload (Cancel As Integer)
  256.     End
  257. End Sub
  258.  
  259. Sub ResetSearch ()
  260. ' Reinitialize before starting a new search.
  261.     lstFoundFiles.Clear
  262.     lblCount.Caption = 0
  263.     SearchFlag = False                  ' Flag indicating search in progress.
  264.     Picture2.Visible = False
  265.     cmdSearch.Caption = "&Search"
  266.     cmdExit.Caption = "E&xit"
  267.     Picture1.Visible = True
  268.     dirList.Path = CurDir$: drvList.Drive = dirList.Path ' Reset DOS path.
  269. End Sub
  270.  
  271. Sub txtSearchSpec_Change ()
  272. ' Update file list box if user changes pattern.
  273.     filList.Pattern = txtSearchSpec.Text
  274. End Sub
  275.  
  276. Sub txtSearchSpec_GotFocus ()
  277.     txtSearchSpec.SelStart = 0      ' Highlight the current entry.
  278.     txtSearchSpec.SelLength = Len(txtSearchSpec.Text)
  279. End Sub
  280.  
  281.