Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword, FolderSpec, FileSpec As String
%IDC_Find = 500
%IDC_Folder = 501
%IDC_File = 502
Function PBMain() As Long
Dialog New Pixels, 0, "Find File",300,300,200,100, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Find,"Find Folders", 30,10,100,20
Control Add TextBox, hDlg, %IDC_Folder,"c:\data", 30,40,140,20
Control Add TextBox, hDlg, %IDC_File,"gbprettyprinter.bas", 30,70,140,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = %IDC_Find And Cb.CtlMsg = %BN_Clicked Then
Control Get Text hDlg, %IDC_Folder To FolderSpec
Control Get Text hDlg, %IDC_File To FileSpec
? GetFolderList (FolderSpec, FileSpec)
End If
End Function
Function GetFolderList(startFolder As String, sFileSpec As String) As String
Local iPos, FolderCount As Long, temp$, fResult$
Dim Folders(100000) As String
Folders(FolderCount) = startFolder
While Len(Folders(iPos))
temp$ = Dir$(Folders(iPos)+"\*.*", Only %SubDir) 'subfolders only
While Len(temp$)
Incr FolderCount
Folders(FolderCount) = Folders(iPos) + "\" + temp$
fResult$ = PathScan$(Full, sFileSpec, Folders(FolderCount))
If Len(fResult$) Then Function = fResult$ : Exit Function
temp$ = Dir$ (Next)
Wend
Incr iPos
Wend
Function = "File not found!"
End Function
'gbs_00841
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm