Copies the contents of the specified memo field in the current record to a text file.
COPY MEMO MemoFieldName TO FileName [ADDITIVE] [AS nCodePage]
- Specifies the name of the memo field copied to the text file.
- TO FileName
- Specifies the name of a new or existing text file to which the memo field is copied. If you do not provide an extension in FileName, a .txt extension is assigned. You can also include a path with the file name.
- Appends the contents of the memo field to the end of the specified text file. If you omit ADDITIVE, the memo field contents replace the contents of the text file.
- AS nCodePage
- Specifies the code page for the text file COPY MEMO creates. Visual FoxPro copies the contents of the specified memo field, and, as it copies the data, automatically converts the data to the code page you specify for the text file. If you specify a value for nCodePage that is not supported, Visual FoxPro generates an error message. You can use GETCP(В ) for nCodePage to display the Code Page dialog box, allowing you to specify a code page for the file Visual FoxPro creates. If AS nCodePage is omitted or is 0, no code page conversion occurs.
In the following example, the contents of the memo field named
notes are copied to a file called Test.txt. The memo field is then copied again and appended to the end of the text file.
CLOSE DATABASES OPEN DATABASE (HOME(2) + 'Data\testdata') USE employee && Opens Employee table COPY MEMO notes TO test.txt WAIT WINDOW 'Memo contents now in test.txt' NOWAIT MODIFY FILE test.txt COPY MEMO notes TO test.txt ADDITIVE WAIT WINDOW 'Memo contents added again to test.txt' NOWAIT MODIFY FILE test.txt DELETE FILE test.txt