Consensus recommendations for the guidelines were based on a search to identify literature on the diagnosis and management of CBP and CP/CPPS (published between 1999 and February 2014). The guideline population were men with CBP or CP/CPPS (persistent or recurrent symptoms and no other urogenital pathology for ≥3 of the previous 6 months). To promote efficient referral of care between non-specialists and specialists and the involvement of the multidisciplinary team (MDT). To provide guidance to healthcare professionals treating patients with CBP and CP/CPPS, in both non-specialist and specialist settings. To improve awareness and recognition of chronic bacterial prostatitis (CBP) and chronic prostatitis/chronic pelvic pain syndrome (CP/CPPS) among non-specialists and patients. Just remember that this method doesn't support the use of Wildcard or other Special Chars, so edMask.Text should be something like. Where edMask is defined in your question as Edit2 and edPath is defined in your question as Edit1. Now here's the modified FileSearch procedure: procedure TFAutoSearch.FileSearch(const ARoot: String) įinally, here's how you initiate your search: procedure TFAutoSearch.btnSearchClick(Sender: TObject) We now need a function to determine if the nominated file matches any of the defined Extensions: function TFAutoSearch.MatchMask(const AFileName: String): Boolean LTempVal := Copy(LTempVal, LPos + 1, Length(LTempVal)) Note this method will not accept Wildcard characters or any other Regex magic, but you can modify it as you require! procedure TFAutoSearch.ExplodeMask(const AValue: String) įMask := UpperCase(Copy(LTempVal, 0, LPos - 1))
This code will populate FMask with each individual mask extension separated by a such as. Now let's provide a "Mask Container" inside the containing class.įMask: TStringArray // Our "Mask Container" TStringArray = Array of String // String Dynamic Array type. What we're going to do is take a String from your TEdit control (this String is one or more File Extensions as you would expect), "Explode" the String into an Array, and match each file against each Extension in the Array. UPDATED: To allow the use of multiple extensions in a Mask dynamically at runtime (as indicated by the OP's first comment to this answer). The code I've provided should work just fine for your needs, so enjoy! While the other answer suggesting the use of multiple extensions as a mask *.cbr *.cbz should (in principal anyway) work, I've noted through bitter experience that the FindFirst and FindNext methods in Delphi tend not to accept multiple extensions in a mask! If (LExt = '.CBR') or (LExt = '.CBZ') then LExt := UpperCase(ExtractFileExt(LRoot + LRec.Name)) If (LRec.Attr and faDirectory 0) and (LRec.Name '.') and (LRec.Name '.') then If FindFirst(LRoot + '*.*', faAnyFile, LRec) = 0 then LRoot := IncludeTrailingPathDelimiter(ARoot) Here's a fully-rewritten version of your FileSearch routine which does exactly what you're trying to do (according to your question, anyway): procedure TFAutoSearch.FileSearch(const ARoot: String) The easiest way is to use ExtractFileExt against the current filename and check to see if it matches either of your desired extensions. Procedure TFAutoSearch.Button1Click(Sender: TObject) įileSearch(Edit1.Text, Edit2.Text, CheckBox1.State in ) If ((Rec.Attr and faDirectory) 0) and (Rec.Name'.') and (Rec.Name'.') thenįileSearch(Path + Rec.Name, FileName, True) If FindFirst(Path + '*.*', faDirectory, Rec) = 0 then If FindFirst(Path + FileName, faAnyFile - faDirectory, Rec) = 0 then Path := IncludeTrailingBackslash(PathName) Space procedure TFAutoSearch.FileSearch(const PathName, FileName : string const InDir : boolean) A listbox to show what it found and a Search button. I have two edit boxes EDIT1 is the location to search, EDIT2 is where i put my mask. I am trying to find all files that have the extenstion.