DOCUMENT:Q113278 30-JUL-2001 [foxpro] TITLE :How to Replace a String in a Text File PRODUCT :Microsoft FoxPro PROD/VER:2.00 2.50 2.50a 2.50b 2.60 | 2.5 OPER/SYS: KEYWORDS: ====================================================================== 2.00 2.50 2.50a 2.50b 2.60 | 2.50 2.50a 2.50b 2.60 3.00 | 2.50b MS-DOS | WINDOWS | MACINTOSH kbprg -------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 3.0 - Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, 2.6 - Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6 - Microsoft FoxPro for Macintosh, version 2.5b -------------------------------------------------------------------- SUMMARY ======= FoxPro does not contain a function for replacing a character string in an ASCII text file. One way to do this is to use low-level file functions. A simpler way is to copy the text file to a memo field, make the change using STRTRAN(), and copy the memo field back to an ASCII file, as demonstrated below. MORE INFORMATION ================ The following steps demonstrate this procedure: 1. Create an ASCII text file that contains the following sentence: This sentence demonstrates how a character string can be changed. 2. Create a database that contains only a memo field. 3. Append a blank record to that database. 4. Create a program that contains the following code: USE APPEND MEMO FROM ,"demonstrates","shows") REPLACE WITH Temp COPY MEMO TO