The Find command on the Search menu allows you to search a file using text strings and regular expressions.
Find can help you locate any string of text in any file you specify. PWB usually searches the file you are currently editing. However, it can also search a list of files. This is particularly useful for finding all occurrences of a string in an entire project.
The results of a multifile search are logged—that is—put into the Search Results window. To see the logged results of a search, choose Search Results from the PWB Windows cascaded menu. There are two ways to use the information that PWB puts into Search Results:
You can look at the matches in sequence by choosing Next Match and Previous Match from the Search menu.
You can go directly to a specific match by moving the cursor to the match listed in the Search Results window and choosing Goto Match from the Search menu. PWB then jumps to the location of the match.
The Match commands on the Search menu work with the Search Results window in exactly the same way that the Project menu's Next Error, Previous Error, and Goto Error commands work with the Build Results window. These Project menu commands are described in “Fixing Build Errors”.
To illustrate the logged-search technique, suppose you want to locate all functions returning an int in the COUNT project's source files.
·To search all the source files in this project:
1.From the Search menu, choose Find.
PWB brings up the Find dialog box.
2.Select the Log Search check box.
3.Type int in lowercase.
4.Select the Match Case check box to exclude uppercase or mixed case occurrences of the word.
5.Choose the Files button.
PWB brings up the Search In Selected Files dialog box.
6.Type CO*.C in the File Name text box.
This wildcard specifies all filenames beginning with CO and having the .C
extension.
7.Choose the Add Pattern button to add the wildcard to the file list.
8.Return to the File Name text box by clicking the box or by pressing ALT+F.
9.Type COUNT.H in the File Name text box.
Because the default button is Add / Delete, you can press ENTER to add COUNT.H to the file list.
10.Add COUNT.H to the list.
11.Choose OK to start the search.
When PWB finishes the search, it displays the Log Search Complete dialog box.
From this dialog box you can:
Choose View Results to open the Search Results window.
Choose Cancel to close the dialog box.
Choose Cancel now (you will open the Search Results window later).
·To go to the first match:
From the Search menu, choose Next Match.
You can step sequentially through all occurrences of the string using the Next Match command. Choose Previous Match to move to the previous occurrence of the string. When you reach the end of Search Results, PWB displays the following message:
End of Search Results
Sometimes, you cannot focus the search narrowly enough to make a sequential scan of Search Results profitable. In this example, you wanted only functions returning int, but PWB found many more occurrences of int. In these cases, you can examine the results of the search and skip the matches that aren't relevant.
·To view the Search Results:
From the PWB Windows cascaded menu on the Window menu, choose Search Results. PWB opens the Search Results window.
In this window, PWB displays the file, line, and column where the string was located. It also shows as much of the matching line as will fit in the window.
For example, if the declaration you want is the one that declares CountWords, you can jump directly to that location.
·To jump directly to a match:
1.Put the cursor on the match.
2.From the Search menu, choose Set Match.
PWB opens the correct file if it is not already open and positions the cursor on the text you located.
You can use multifile searching regardless of whether the files that you want to search are open in PWB. For example, you can search $INCLUDE:*.H (all the headers on the INCLUDE path) for a particular prototype.