REPLACE V1.1 REPLACE is a program designed to copy a file, and as it does so, to replace certain sets of characters (called KEY STRINGS or KEYS) with other such sets. Key strings may be specified from the computer keyboard, or from a previously created disk file. OPERATION: Type REPLACE and hit a carriage return. You will be asked to specify the file in which the replacements are to be made (the INPUT file), and the file to receive the changes (the OUTPUT file). You will then be asked how the keys are to be input, either from the keyboard, or from a file. If you choose the keyboard option you will be prompted for keys to be found and what they are to be replaced with. When you want to start the replacement process, just hit a carriage return when prompted for the next key to be found. If the file option is chosen, you will be asked for the name of the file that contains the keys to be found and replaced (how to prepare such a file is discussed below). The program will then read in the keys, display them on the screen, and automatically start the replacement process. SPECIFYING KEYS: Simple alpha-numeric keys are formed by simply typing in the letters or numbers you wish to find and replace. Spaces and other characters that appear on the keyboard may also be entered in this fashion, with the exception of the character ^. ^ may be used to enter characters that do not appear on the keyboard, such as control characters and carriage return and line-feed characters. Its use may take four forms. They are: 1) ^^ - represents a single ^ in the key string. 2) ^A - where A is any letter A-Z. It represents the corresponding control-character in the key string. 3) ^(###) - where ### is a 1 to 3 digit decimal number. It represents character number ### of the ASCII sequence in the key string. 4) ^(##H) - where ## is a 1 or 2 digit hexadecimal number. It represents character number ##H of the ASCII sequence in the key string. Using these forms all ASCII characters 0-255 may be represented in either the FIND or REPLACE keys. The format of keys is the same, regardless of whether they are entered from the keyboard or from a file. PREPARING A FILE CONTAINING KEYS A file containing keys may be prepared on any word processor or editor that uses ASCII files (WordStar should be used in the Non-Document mode). The file should contain pairs of lines. On the first line should be the string you want to FIND and on the second line should be the string you want to REPLACE it with. Pairs of key strings should be separated by one blank line. Key strings may be up to 80 in length and there is a limit of 30 pairs allowed. USING OPTIONS Two options are provided to aid in the use of the program. Both apply only to the finding of matches between the find key and the source text. They do not apply to the replace key. The first option is to ignore the parity-bits in the source file. Some background: there are eight bits used to describe the 256 different characters in the ASCII character-set. Only 7 bits are needed to specify all of the characters on the keyboard, plus the control characters. The eighth bit (here called the parity- bit) is not normally used. However, some programs, notably WordStar, use this eighth bit to mark the end of words and differentiate between "soft" and "hard" carriage returns. The default for the program is to ignore this eighth bit. For instance, the letter "E" will match up with both character numbers 69 and 196 (=127+69) (decimal) in the ASCII sequence. If this option is turned off, "E" would only match character number 69. This option does not affect matches where the eighth bit has been set in the find key. ^(196) matches only character 196, no matter which option is selected. The second option directs the program to ignore differences in case when searching for the occurrence of a key in the source file. For instance, if this option is selected "E" will match both "E" and "e". If this option is not selected, it will match only "E". The default setting for the program is to pay attention to differences in case. LIMITATIONS: 1) The program may run out of memory space if the key strings to be replaced are much larger than the keys to be found and occur frequently. If this occurs, the program will terminate with run- time error FF. To get around this problem, use fewer sets of keys at one time, or make the replace keys shorter. 2) If there is not room on the disk for the output file, I/O errors F0 or F1 may occur and cause program termination. 3) The only character that will not work as a find key in this program is ^Z (control-Z, ASCII 26 or 1AH) which is used as an end-of-file marker. 4) The program is designed for mass replacing. It does not query to be sure that it only replaces what you want replaced. Make sure that your keys to be found and replaced are unique enough that only the correct substitutions are made. EXAMPLE In Source file : This is an exameple of some Tex Find Key 1 : Tex Replace Key 1 : TEXT Find Key 2 : me Replace Key 2 : m In Output file : This is an example of som TEXT Note that the loss of the letter "e" from the word "some" would not have occurred if we had used the find key "ame" (with replace key "am" instead of just "m"). 5) Replaces are done sequentially, in the order in which they are entered. This means that if a replace key (or a portion of) is used later as a find key, that replace key (or portion of) will be itself replaced. POTENTIAL USES 1) To save keystrokes when writing. Use abbreviations for frequently used words or phrases. Set up a file containing the abbreviations as the find keys and the words or phrases as the replace keys. 2) To rapidly insert print controls while using WordStar. If there is a word or phrase that needs to be always underlined (for example : et al.) use the word as a find key (et al.) and for the replace key, use the word plus the required print controls (^Set al^S.). 3) To convert files from other word-processing programs to WordStar. Find ^M and replace it with ^(140) to convert all the hard carriage returns to soft ones. WordStar is a trademark of MicroPro International Corp. The REPLACE program is free for public distribution, but may not be sold without the written authorization of John Porter. Copyright (c) 1985 by John Porter