Skip to main content
Thoughts from David Cornelius

Category

You've probably used Delphi's Find in Files feature to search for an identifier or library function through multiple folders of source code. If you have backups of your source or multiple projects with copied or similar sets of routines and check the "Include subdirectories" checkbox, the search results could contain a lot of duplicates taking extra time to wade through them all. Wouldn't it be nice if there was a way to fine-tune the folders being searched?

There is!

Delphi's Find-in-Files dialog box.When you pull up the Find in Files dialog and select the "Search in directories" option in the "Where" group, the Directories text box is enabled to allow you to specify a folder to search. This is a good starting point but if there are many folders to search through, it can not only take a while but large result sets can be overwhelming to comb through; unchecking "Include subdirectories" may not be enough for you to find what you need if you can't remember what folder your source is or if you want to compare how something was used in different projects.

To the right of the Directories edit box are two small buttons. The first one, Browse for Folder, allows you to select a single folder and when you click OK, it replaces the text in the Directories edit box with the result, making it easy to drill down through a folder tree and enter it correctly.

The second button is where the real flexibility comes in. Click "Folders and Groups" and you'll see a "Select Directories" (notice it's plural) dialog appear allowing you to add multiple directories. When you click OK, it puts the list of directories listed in the "Directories to search" box in the top half of the window, in the Directories text box, separated by semicolons. Now, uncheck "Include subdirectories" and you have a concise list of folders to search, ignoring ones you don't want included.

This is great but wait--there's more!

Let's say you have different sets of projects or libraries or even folders with different versions of Delphi that you want to search through frequently and don't want to re-select those directories each time you need to Find in Files. The bottom half of the "Select Directories" dialog allows you to create saved lists of selected directories in named groups and then reuse those groups.

For example, I have a product called CCIntegrator which has several plugins, some generic, and some customer-specific. So I created a group to search through the source of all those plugins but did not include the customer-specific ones. I called the group "ccIntegrator" and whenever I want to search for something in that product, I select that group, click the little up-arrow next to it which puts "@ccIntegrator" into the top half of the dialog, then when I click OK and start the search, it'll search through that named group of folders.

With the flexibility of Delphi's Find in Files feature, I can search through source in a single folder, multiple folders, or multiple named-groups of folders!

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
Please enter the characters shown; no spaces but it is case-sensitive.
Image CAPTCHA
Enter the characters shown in the image.