Page 1 of 1
ExamineDirectory with multiple patterns?
Posted: Wed Apr 01, 2009 11:38 am
by Mistrel
Is it possible to use ExamineDirectory with multiple patterns? I tried several combinations and wasn't make to make it work. I'm currently filtering by passing my own pattern string and comparing each file myself. I'm just curious if there is some native functionality that's not described in the documentation?
Posted: Wed Apr 01, 2009 1:46 pm
by Trond
No, it's not possible.
Posted: Tue Aug 11, 2009 2:12 pm
by PB
Anyone know if this is planned for a future release?
Posted: Tue Aug 11, 2009 2:15 pm
by nco2k
yep, its planned since 2005.
c ya,
nco2k
Posted: Tue Aug 11, 2009 2:20 pm
by PB
I know, I was bumping the request by making it look innocent.

Posted: Tue Aug 11, 2009 4:59 pm
by AND51
It would be good to have this feature implemented.
The pattern for
ExamineDirectory() should be similar to the pattern of
OpenFileRequester():
Code: Select all
ExamineDirectory(0, "C:\pictures\", "*.bmp|*.jp?g|*.png")
In the requester, you can also use multiple pattern by separating them with a | vertical bar.
This would even increase consistency within PureBasic; and obviously, consistency is an important point for Fred and Freak.
Posted: Tue Aug 11, 2009 11:12 pm
by idle
Code: Select all
Procedure Findfiles(*fn,StartDirectory.s,pattern.s,Recursive=1)
Static strFiles.s,ct1,ptc,bPattern
Protected k,ct
If Not bPattern
tpattern.s = RemoveString(pattern,"*")
ptc = CountString(tpattern,"|")
Static Dim pt.s(20)
For k=1 To ptc+1
pt(k-1) = StringField(tpattern,k,"|")
Debug pt(k-1)
Next
bPattern = #True
EndIf
mDir = ExamineDirectory(#PB_Any, StartDirectory, "*.*")
If mDir
While NextDirectoryEntry(mDir)
If DirectoryEntryType(mDir) = #PB_DirectoryEntry_File
Directory$ = StartDirectory
FileName.s = DirectoryEntryName(mDir)
ct=0
While ct <= ptc
If FindString(FileName,pt(ct), 1)
FullFileName.s = StartDirectory + "\" + FileName
If CallFunctionFast(*fn,FullFileName) = 0
Break 2
EndIf
Ct1 + 1
EndIf
ct+1
Wend
Else
tdir$ = DirectoryEntryName(mDir)
If tdir$ <> "." And tdir$ <> ".."
If Recursive = 1
Findfiles(*fn,StartDirectory + "\" + tdir$,"")
EndIf
EndIf
EndIf
Wend
FinishDirectory(mDir)
EndIf
ProcedureReturn ct1
EndProcedure
Global NewList myfiles.s()
Procedure MyCallBack(ResultString.s)
PrintN(ResultString)
ProcedureReturn #True
EndProcedure
OpenConsole()
count = FindFiles(@MyCallBack(),"C:\Pictures", "*.bmp|*.jpg|*.png",1)
PrintN(Str(count))
Input()