@Trond ~ @TerryHough
sorry I couldn't reply earlier - but I was heavily fighting with the codes
Thanks for the recursion example which is very descriptive to track
TerryHough wrote:Vera wrote:
Note: the ExplorerListGadget(0, 0, 0, 0, 0 ... doesn't show much ... o

On purpose. It prevents screen-flicker in this case since the ExplorerGadget's display is never being used...
I see - and realised that I got trapped thinking I'd get a result-view of found files. So I enhanced your code in that sense to gain an optical
(flicker-free) output.
By this, one can crosscheck the results and I now stumbled across the amount of 'Count'-results which can vary strangely and do not allow to allocate which selection they concern. The hits mostly fit
(although I've seen rare misscountings there as well). I haven't figured out why this happens - if it's because 'Count' is prossed twice or due to Windows special habits with the asterix (*).
Could you have a look if you experience something similar like: 3 found files / total Count 190 files - while there are only 20 files inside the folder (w/o sub) and the summed up found files is also far below this amount.
greetings ~ Vera
Code: Select all
Global item, count2
Procedure RecursivelyExploreDirectory(SourceDirectory$, Start, Pattern$)
If ExamineDirectory(Start, SourceDirectory$, "*.*")
Debug SourceDirectory$
While NextDirectoryEntry(Start)
Select DirectoryEntryType(Start)
Case #PB_DirectoryEntry_Directory
If DirectoryEntryName(Start) <> "." And DirectoryEntryName(Start) <> ".."
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
a$ = SourceDirectory$+DirectoryEntryName(Start)+"/"
CompilerElse
a$ = SourceDirectory$+DirectoryEntryName(Start)+"\"
CompilerEndIf
Start+1
RecursivelyExploreDirectory(a$, Start, Pattern$)
ExplorerListGadget(0, 0, 0, 400, 100, a$ + pattern$, #PB_Explorer_NoFolders | #PB_Explorer_NoParentFolder)
If CountGadgetItems(0) > 0
Count + CountGadgetItems(0)
;Do whatever you need to with the resulting explorer file list
; MessageRequester("Find Files", a$ + #LF$ + Str(CountGadgetItems(0)) + " matches in folder" + #LF$ + Str(Count) + " total files (of what ?) "); , #MB_ICONINFORMATION
EndIf
Start-1
EndIf
EndSelect
Wend
FinishDirectory(Start)
ExplorerListGadget(0, 0, 0, 400, 100, SourceDirectory$ + Pattern$, #PB_Explorer_NoFolders | #PB_Explorer_NoParentFolder) ; ,
If CountGadgetItems(0) > 0
Count + CountGadgetItems(0)
colo = RGB(Random(155)+100, Random(155)+100, Random(155)+100)
For n=0 To CountGadgetItems(0)-1
file$ = GetGadgetItemText(0, n)
spath$ = RemoveString(GetGadgetText(0), GetCurrentDirectory())
AddGadgetItem(item, -1, file$ +Chr(10)+ GetExtensionPart(file$)+Chr(10)+ spath$)
SetGadgetItemColor(item, CountGadgetItems(item)-1, #PB_Gadget_BackColor, colo , 2)
SetGadgetState(item, CountGadgetItems(item)-1)
Debug file$
Next n
count2 + n
Debug Count
Debug count2
AddKeyboardShortcut(0, #PB_Shortcut_Space, 0) ; Spacekey to skip timeout
startTime=ElapsedMilliseconds()
Repeat
wwe = WaitWindowEvent(100)
If wwe = #PB_Event_CloseWindow : End : EndIf
If wwe = #PB_Event_Menu And EventMenu() = 0 : startTime =0 : EndIf
Until ElapsedMilliseconds()-startTime > 1300 ; en-/decrease timeout for listupdate
; Do whatever you need to with the resulting explorer file list
; MessageRequester("Find Files of: " + Pattern$ , SourceDirectory$ + #LF$ + Str(CountGadgetItems(0)) + " matches in folder" + #LF$ + Str(Count) + " total files (of what ?)" + #LF$+ #LF$ + Str(count2) + " summed finds") ; , #MB_ICONINFORMATION
EndIf
EndIf
ProcedureReturn Count
EndProcedure
dir$ = #PB_Compiler_Home
;dir$ = "C:\"
;dir$ = "/home"
SetCurrentDirectory(dir$)
Pattern$ = "*.exe;*.txt;*.png"
If OpenWindow(0, 130, 130, 400, 405, "ExplorerListGadget", #PB_Window_SystemMenu ) ; | #PB_Window_ScreenCentered
item = ListIconGadget(#PB_Any, 0, 100, 400, 300, "Files", 135, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(item, 1, "Ext", 35)
AddGadgetColumn(item, 2, GetCurrentDirectory(), 210)
Files.l = RecursivelyExploreDirectory(GetCurrentDirectory(),1, Pattern$)
MessageRequester("Find Files by: "+ Pattern$, "Total "+ #LF$ + GetCurrentDirectory()+ #LF$+#LF$+ Str(Files)+ " files"+ #LF$ + Str(count2)+ " summed finds") ; , #MB_ICONINFORMATION
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
End