Posted: Mon Dec 17, 2001 12:12 pm
				
				Restored from previous forum. Originally posted by Fangbeast.
 
 
Fangles
			Code: Select all
 ;--------------------------------------------------------------------------------------------------------------------------
Procedure GetList(SourceDirectory$, Start, Pattern$)
  
  Shared Counter
  
  If ExamineDirectory(Start, SourceDirectory$, "*.*")
    Repeat
      Type = NextDirectoryEntry()
      If Type = 2
        If DirectoryEntryName()  "." And DirectoryEntryName()  ".."
          a$ = SourceDirectory$ + DirectoryEntryName() + "\"
          GetList(a$, Start + 1, Pattern$)
          UseDirectory(Start)
        EndIf
      Else
        If Type = 1 And FindString(UCase(DirectoryEntryName()), UCase(Pattern$), 1)  0
          Place$ = SourceDirectory$ + DirectoryEntryName()
          SetGadgetText(5, "   " + Str(Counter) + " Matches")
          SetGadgetText(6, SourceDirectory$) 
          AddGadgetItem(7, -1, Place$)
          Counter + 1
        EndIf
      EndIf
    Until Type = 0
  EndIf
  
EndProcedure
;-------------------------------------------------------------------------------------------------------------------------
; StartDrive$ = PathRequester("Select the Drive and the DIRectory to CATalogue please", "C:\")  ; Drive, Dir to cat
; Setup the number of gadgets for the initial display
;--------------------------------------------------------------------------------------------------------------------------
InitGadget(12)
#SearchItem = 2
#SearchLocation = 3
#StartButton = 4
#NumGadget = 5
#DirTitle = 6
#ListBox = 7
#Frame3D = 8
#ButtonLength = 125
#ButtonHeight = 25
#ButtonX = 5
#ButtonY = 15
SetGadgetFont(2)
If OpenWindow(0, 5, 5, 800, 590, #PB_Window_SystemMenu,"iFind, v2")
  If CreateGadgetList(WindowID())
    StringGadget(#SearchItem, #ButtonX, #ButtonY, #ButtonLength, #ButtonHeight,"")
    ButtonGadget(#SearchLocation, #ButtonX,45, #ButtonLength, #ButtonHeight,"Search Where?")
    ButtonGadget(#StartButton, #ButtonX,75, #ButtonLength, #ButtonHeight,"Start Searching")
    TextGadget(#NumGadget, #ButtonX, 105, #ButtonLength, #ButtonHeight, "")
    TextGadget(#DirTitle, 135, #ButtonY, 655, #ButtonHeight, "")
    ListViewGadget(#ListBox, 135, 45, 655, 500)
    Frame3DGadget(#Frame3D, 1, 1, 793, 555, "iCat Utility", 0) 
  EndIf
EndIf
GadgetToolTip(2, "Type in the item you are searching for, case insensitive, don't use WildCard characters")
GadgetToolTip(3, "Select the Drive and DIRectory where you want to start your search from")
GadgetToolTip(4, "Click on this button to actually start the search from your details")
GadgetToolTip(5, "This progress bar will show you just how far into the search you are")
GadgetToolTip(6, "This box will show the name of each directory passed through by the search")
GadgetToolTip(7, "Double Click on an item in this list to launch it with the associated program")
Repeat                                                                            ; Repeat the following loop
  EventID.l = WaitWindowEvent()                                                    ; What sort of event to wait for
  If EventID = #PB_EventGadget                                                    ; What event inside event type to act on
    Select EventGadgetID()                                                       ; Check for buttons being pressed
      Case #SearchLocation                                                       ; If searchbox button pressed
      ClearGadgetItemList(#ListBox)                                               ; Clear previous searches
      StartDrive$ = PathRequester("Select Drive and DIRectory to search", "C:\")  ; Get the drive and directory
      Case #StartButton                                                           ; If Star search button pressed
      Counter = 1                                                                 ; Zero the item counter
      Target$ = GetGadgetText(#SearchItem)                                        ; Get the target data
      If StartDrive$ = ""                                                         ; If no drive selected,
        StartDrive$ = "C:\"                                                       ; Default to drive C:\
      EndIf                                                                       ; Otherwise end
      GetList(StartDrive$, 0, Target$)                                            ; Start the search
    EndSelect                                                                    ; No more choices to process
    If DoubleClick() = 1                                                          ; if an item in the list is double clicked
      ItemString$ = GetGadgetText(#ListBox)                                        ; Get the data back from it
      If RunProgram(ItemString$, "", 0)                                            ; Feed it to a DOS shell
      EndIf                                                                        ; Otherwise end
    EndIf                                                                          ; Otherwise end
    If GetGadgetState(#ListBox)  -1                                              ; If an item in the list is selected
      ToolBox$ = GetGadgetText(#ListBox)                                           ; Get the data back from it
      ToolBox$ = GetFilePart(ToolBox$)                                             ; Return only the filename
      GadgetToolTip(7, ToolBox$)                                                   ; Make it popup as a tool tip
    EndIf                                                                          ; Otherwise end
  EndIf                                                                            ; Otherwise end
Until EventID = #PB_EventCloseWindow                                               ; No more events to process
End                                                                                ; End the program