SRCHRP9D.PRG -- A Very Versatile Search/Replace Utility 1/10/94 This is Freeware, Not shareware. Feel free to use it all you want and give it away. Version 9D -- Fixed replacement with string longer than original. Provide 100K and 400K buffer size options as SR9D100.PRG and SR9D400.PRG. I know it's not a very sophisticated way to do it, but it was EASY. This also adds an eXit (no save) option to menu. Version 9C -- 400,000 byte buffer, instead of 64K limit. This means you must have that much free memory available plus what the program code itself takes up. * GEM file selector. * Menu that allows: Find/Replace with a bunch of wildcard options, Display file in buffer (everything, not just text), Read new file into buffer, Save current buffer to file, Quit (and save) * Added replace option to skip a user chosen number of matches between replacements. (I once needed to delete every other cr/lf pair from a file, so this handled it all in about 2 seconds). * It tells you the number of replacements made after each operation. * Works fine in any resolution. * Handles files only up to 64K. Background ---------- Why do I need this when all editors have built-in search/replace functions?? If all you deal with is text, that MIGHT be fine. But what if you want to replace all the CR codes with CR/LF? (yes SOME editors will let you do this -- e.g. Flash.) But what if you wanted to replace any number followed by a period with the same number enclosed in parentheses? Or you want to change the first letter of every word to upper case? Or you have a data file with numbers (i.e. the full range of characters 0-255, not just nice ascii characters) in it and for some reason you want to change all the CHR(155)'s to CHR(182). With this you can do it. Of course it also lets you choose between case sensitive or insensitive on any search with ASCII text in the search string. Examples -------- To replace a variable number of spaces between words with just a single space, you should be able to just search for 2 spaces and replace with one space. However, since this increments the position by one with each replacement, it will require multiple passes. To make for a little less work, you can do earlier passes searching for say 5 spaces and replacing with 1, and then maybe 3 and finally as many 2's as needed until you get no more replacements. To un-capitalize everything but the first word of a sentence (assuming you just want the first letter of the first word capitalized): First, just search for an alpha wildcard (A-Z & a-z) and replace it with lower case. This makes everything lower case. Then search for a period followed by two spaces and an alpha wildcard, and replace it with a period followed by two spaces and a capital wildcard. This assumes your text follows the normal convention of two spaces after each period. Finally, you'll have to do something to get the first character of the first sentence, since it won't have a period before it. Just search for an alpha wildcard and replace with a capital wildcard, and then quit after replacing the first character. Written in TDI Modula-2 (after converting the first version from Kyan Pascal back on the 8-bits). If you would like the source code or more complete documentation or want any more features, then try sending me at least $10 along with a note describing your wishes. (I wouldn't want you to think I'd refuse more if you feel overwhelmed with gratitude.) EdHak copyright (c) 1990-1994 by: Craig A. Harvey (author of DIARY/EdHak, but SRCHREP was written before DIARY) For the full version of EdHak, in Europe contact: Douglas Communications P.O. Box 119, Stockport, Cheshire SK2 6HW United Kingdom Telephone: 061-456 9587 Fax: 061-456 9587 In the USA contact: GEnie: c.harvey CompuServe: 73047,600 Clear Thinking 2753 Plymouth Rd, Suite 137 Ann Arbor, MI 48105 USA 313-971-6035 (by modem) 313-971-8671 (voice)