Search/Replace Contents
Search/Replace String Table of Contents

Topics:

Application Synopsis

File Extension Override Dialog

File Extension Query Dialog

File Types Dialog

Preferences Dialog

Registration Form

Replace Query Dialog

Search/Replace Dialog


Application Synopsis

The Search/Replace application was built to allow application developers, html writers, system/network administrators, and others to change a key word or phrase in many lines of many text files quickly and efficiently.  Application developers can, for example, wire it into the Microsoft C++ visual work bench through its Options/Tools menu to enrich the editing capability.  It can also be used stand-alone by developers or administrators who need to change a piece of information in one or more lines of many files located in a single directory.

Search/Replace allows you to:

•	define the search and replace strings;

•	define whether or not the search will be case sensitive (replace is always as typed);

•	define whether or not it must find the search string as a whole word or allow it to be embedded;

•	control whether the replace operation will be global or a confirmation is required for each replace (it will allow you to change from confirm each to global during the confirmation process);

•	select one or more files you want it to search (limited to a single directory);

•	define whether to replace all instances in a line or only the first;

•	define the file extensions you want to Always Search or Exclude (prompts you when it encounters an extension not on one of the two lists or allows you to add it to one of two additional lists which are search/exclude for this session only);

•	include an extension to search from its always exclude list for a specific session;

•	define whether the files it searches conform to the UNIX file type rules for end-of-line (discussed

•	below);

•	abort/stop in the middle of a replace session when confirm each is selected;

•	change from search/replace to insert a string at a specific column in every line of the files you select (discussed below); and

•	use a limited set of special characters (tab, formfeed, carriage return, and newline) to add/change text at the end-of-line, convert spaces to tabs or vice versa, and control how you printer responds (discussed below).

The application was designed to handle in excess of 1000 files as long as only a few lines per file are changed (the number of files multiplied by the number of lines modified per file equal display limitation).  The application expects to find newline characters, as a minimum, at the end of each line (text file) and will not process files that are not constructed in this manner.  Files generated by word processors generally do not fall into this category unless they are saved in ASCII/text.  When the application encounters such a file, it warns you and excludes the file extension from any further searches during the session.

Files are generally grouped by extension, and in todays environment, more than one type of file can have the same extension.  As one example, Microsoft Word stores their files by default in non-text format using the doc extension while you or others may use the same extension to store files in text format.  Search/Replace makes no assumptions about file types except for a few universal ones such as exe, com, etc.  You must define the file extensions you do and do not want included in your search.  You need not predefine the extensions, since the application will prompt you each time it encounters an extension it does not know about.  The application keeps five (5) file extension lists which are Always Search, Always Exclude, Search This Session Only, Exclude This Session Only, and Override an always excluded extension for this session only.  You may predefine the Always ... file extension types in the Options/File Types menu.

Any time a file is modified by the application, a backup files is generated that contains the original information.  If you choose to Abort a search/replace operation, all files modified during the session up to the Abort point are restored via those back ups to their pre-session state.  You may also decide, after the fact, that the changes made were not as expected and manually restore them yourself.  By default the original files extension will begin with a tilde (~) followed by up to the first two characters of the original file extension.  If a tilde is not to your liking , you may change it to a valid file name character of your choosing in the Options/Preferences menu.

In todays networking environment, many files can be manipulated on foreign machines.  The UNIX file type option is available for those who need to remotely alter text files that conform to the UNIX file standard.  For those not familiar with UNIX Vs DOS file types, UNIX saves file with just a newline (\n) while DOS saves files with a carriage return (\r)-newline(\n) combination.  When you are using the end-of-line characters to insert/replace, you must be aware of their respective formats.  To help you remember, the carriage return character is not displayed in the allowed special character set when the UNIX file types box is checked.

There have been times when I needed to insert a character or a character string at a specific column of every line in a data file and had to do it manually.  As an added bonus, the application will do that for you if you check the Insert @ Column box in the Search/Replace Dialog.  Instead of a search replace application, the application magically changes to insert at a column.  The search/replace string captions change as well as the functionality of its controls allowing you to define the character or string and the column (1 through 254 minus the insert string length) where you want it inserted.  Be aware, that formerly blank lines will contain the inserted string at the specified column at the conclusion of the operation.


Exclude File Extension Override Dialog

There will be times that you want to search a file type that you have on your Always Exclude list.  You can accomplish this for the current session by clicking the Override button in the Search/Replace Dialog.  The OverRide dialog will appear with all excluded file extensions listed.  Select the extension(s) you want to search this session and press the Copy button and the extensions are copied to the Override list.  If you accidentally copied an extension to the Override list, simply select it and click the Delete button to remove it.


Search/Replace Dialog

The Search/Replace dialog allows you to type in the explicit Search and Replace Strings.

Actions that will result from checking/clicking a box/button are:

Match Case:	 If you want your search and replace to be case sensitive, make sure you type the search string case explicitly and check the Match Case control, otherwise, case is ignored.  Replacements are always made exactly as the replace string was typed.

Match Whole Word Only: 	 Checking the Match Whole Word Only control effectively causes a space to be added before the first character and also after the last character during the search.  This could cause consternation if the word can end a sentence or is located at the end of a line.

First Instance Only:	If you check the First Instance Only control, the search for replace is suspended after the first instance in a line is found.  To replace all instances of the Search String in the files selected, check the All Instances in Line control.

All Instances:	If you check the All Instances control, all strings found within a line matching the Search String are candidates for replace with the Replace String.

Global Replace:	If you check the Global Replace control all instances of the Search String found will be replaced with the Replace String for the files you select and there will be no confirmation.

Confirm Each Replace:	As you would expect, you get to confirm whether or not to replace every instance in every file where the application finds the Search String.

UNIX File Types:	If you are changing text files remotely and the foreign machine supports UNIX file types, check the UNIX File Type control.  You may get unexpected results if you check the UNIX File Type control and are modifying DOS type files.  Conversely, you may also get unexpected results if you are saving your files in UNIX end-of-line format in DOS.

Inserting a String:	You can change the way Search/Replace acts by checking the Insert String @ Column control.  When you check that control, you will notice that the Search/Replace String captions change to Insert String and At Column respectively.  Instead of searching each line for the Search String, the application will now insert the Insert String in every line of every file at the column you specify, including previously blank lines.

Special Characters:	A limited number of special characters can be included in the search/replace or insert operations.  All characters in the Search and Replace Strings are treated literally until you click the Special Char button.  Clicking that button allows you to add one of the special characters identified in the pop up list to the end of the Search or Replace String.  The string the character will be appended to is identified by the arrow just to the right of the string entry controls.  Special characters are displayed as \t-tab, \f-formfeed, \n-newline, and \r-carriage return.  Once you have added a special character, any of the above characters beginning with the \ followed by a letter take on the new meaning and are NOT treated literally.  If you are familiar with the terminology, you can simply type the literal characters into either control after the first has been added instead of continually clicking the Special Char button to add them.  There is no way to back down, except to Cancel, if you change your mind after clicking the Special Char button.  You can continue on if you delete or exchange the characters, but any of the above characters preceded by the \ will be treated as special characters.

Override:	If you wish to override one or more file extensions on the Always Exclude list for this search/replace session, click the Override button and add the extension(s) to the list.

Selecting Search Files:	Click the Select Files button when you are ready to define the files you wish to include in the search.

Begin:	Once you have selected the search files, click the Begin button to the begin the search/replace operation.


Query Dialog
Replace Query Dialog

The replace query dialog allows you to make judgments about whether or not you wish to replace each instance of the Search String found in the selected files.  The dialog displays the current file name and line number where Search String has been found and highlights characters.  By clicking one of the following buttons you will get the following results:

Replace It:	causes the current instance of the Search String to be replaced by the Replace String;

Skip This One 	causes the current instance to be skipped, that is, not replaced;

Do Remainder:	causes this occurrence and all future occurrences of the Search String encountered to be replaced by the Replace String (Clicking it is like checking the Global Replace control after the fact);

Stop Now:	 causes the current occurrence to be skipped, all future occurrences in the current file to be skipped, and cancellation of any further searching, however, all previous operations are preserved; and

Abort:	 causes all changes made to all lines in all files searched to this point to be reversed and cancels any further searching.


File Extension Query during Replace
File Extension Query During Replace Dialog

During a search/replace operation when the application encounters a file not on the Always Search, Always Exclude, Search This Session Only, or Exclude This Session Only lists, you will be presented with this dialog allowing you to dictate to the application how to deal with the extension.  You must check one of its buttons or accept the default.  The four options you have are:

Add to Always Search List:

Adds the file extension to the Always Search list and will search the extension in this and all future sessions!

Add to Exclude List:

Adds the file extension to the Always Exclude list so henceforth all files with that extension will NOT be searched!

Add to Search This Session Only list:

Doesn't add the file extension to the Always Search list but will search files with that extension during This session ONLY!

Add to Exclude This Session Only list:

Doesn't add the file extension to the Always Exclude list and will NOT search files with that extension during This session ONLY!


File Types Dialog

The file types dialog allows you to add extensions to the Always Search or Always Exclude lists.  Always is probably a poor choice of words since one of the options is to delete file extensions from either list.  However, its intent is allow you to semi-permanently define file extensions that you typically search so you wont be nagged by the dialog that appears every time the application encounters an extension it doesnt know about.

Adding a File Extension:	To add an extension, simply type the extension into the control and press Add.  You can add to both lists at the same time if you type an extension into both controls.  If the extension already exists, it will not be duplicated.  If the extension exists in the other list, you will get a warning that it is already on the other list but will have the option of adding it anyway.  Note that the decision precedence for searching /excluding is search first.  If the extension is allowed to remain on both lists, it is, therefore, SEARCHED.  You will not be allowed to add extensions containing non-valid DOS file characters.  If you predominately operate on UNIX file types having extensions greater than three characters, you will need to add those extensions when nagged since you cannot add them directly.  You may, in addition to adding file extensions.

Moving Extensions:	To  Move one or more extensions from one list to the other, simply select the extensions by clicking on the extension and clicking the appropriate Move button.

Deleting Extensions:	To delete extensions, select the extension you want to delete and click the appropriate Delete button.


Preferences Dialog

Tab Characters:	When a tab character is encountered in line being displayed in the Replace Query dialog, the tab character is expanded using spaces to preserve appearance.  If the Special Char button was pressed, all special characters are displayed and since they are not printable, they appear as a solid vertical bars in the display which allows you to see that a special character exists at that point.  Since the tab is a special character, it is expanded in normal displays to eliminate the unsightly and possibly confusing resulting character.  You may define how many spaces will be displayed in lieu of the tab by entering the number of your choice between 1 and 24.  The default is 4.

Back Up File Character:	You may choose a different beginning file extension character as the first character in the back up file created when a file is modified.  By default the back up character is a tilde (~).

How to Display:	You may also select whether the display of the original and modified lines uses a proportional or fixed character spacing font.  Default is fixed.  (Note print outs are forced to fixed character spacing).


Registration Form

Name: _____________________________________________

Note:	Type/print your name and company below exactly as it appears in the registration dialog in

the Help Menu of the Search/Replace or Find String Application.

Name: _____________________________________________

Company:__________________________________________

Please type or print clearly the following information:

City: _________________________________      State: _____      Zip: __________

E-Mail Address: _______________________________

Check the programs you wish to Register.

Search/Replace String	_____  $15.00

Find String	_____  $15.00

Both Search/Replace & Find String	_____  $25.00

I have enclosed a

___ Check	___Money Order	(Check One)

Preferred Registration Code delivery:

___ Mail	___ E-mail	(Check One)

Please include a self addressed envelope for mail delivery to speed up the response.

---------------------------------------------------------------------------------------------------------------------------------------

Please make checks payable to Richard Floersch.

Mail this form and your check or money order to:

Richard Floersch

7307 W 89th Terrace

Overland Park, Ks	66212

___________________________________________________________________________________