Microsoft KB Archive/110539: Difference between revisions
(importing KB archive) |
m (Text replacement - "&" to "&") |
||
(3 intermediate revisions by the same user not shown) | |||
Line 27: | Line 27: | ||
<li><p>Load the text file into an editor that recognizes the linefeed characters, and then use the editor's search and replace feature to replace each linefeed with a carriage return.</p> | <li><p>Load the text file into an editor that recognizes the linefeed characters, and then use the editor's search and replace feature to replace each linefeed with a carriage return.</p> | ||
<p>To do this using the FoxPro file editor, perform the following:</p> | <p>To do this using the FoxPro file editor, perform the following:</p> | ||
<p>1. In the Command window, type | <p>1. In the Command window, type "MODIFY FILE <filename>" (without</p> | ||
<pre> the quotation marks).</pre> | <pre> the quotation marks).</pre> | ||
<p>2. From the Edit menu, choose Find.</p> | <p>2. From the Edit menu, choose Find.</p> | ||
<p>3. In the Look For text box, type | <p>3. In the Look For text box, type "\n" (without the quotation</p> | ||
<pre> marks) to search for the linefeed.</pre> | <pre> marks) to search for the linefeed.</pre> | ||
<p>4. In the Replace With text box, type | <p>4. In the Replace With text box, type "\r\n" (without the quotation</p> | ||
<pre> marks) to replace the linefeed with a carriage return and a linefeed.</pre> | <pre> marks) to replace the linefeed with a carriage return and a linefeed.</pre> | ||
<p>5. Choose Replace All.</p> | <p>5. Choose Replace All.</p> | ||
<p>NOTE: For more information on searching for special characters, see the following sections of the online Help file:</p> | <p>NOTE: For more information on searching for special characters, see the following sections of the online Help file:</p> | ||
<pre> - FoxPro FOXHELP.HLP online Help file, | <pre> - FoxPro FOXHELP.HLP online Help file, "Find Dialog" jump text, | ||
under the | under the "Interface A-Z" topic</pre> | ||
<pre> - FoxPro FOXHELP.DBF online Help file, | <pre> - FoxPro FOXHELP.DBF online Help file, "Find" topic, under "The | ||
FoxPro Interface | FoxPro Interface" section</pre> | ||
<p>-or-</p></li> | <p>-or-</p></li> | ||
<li><p>Write a program that performs low-level file I/O and adds a carriage return to each line, as shown in the following sample program.</p> | <li><p>Write a program that performs low-level file I/O and adds a carriage return to each line, as shown in the following sample program.</p> | ||
<p>USE SYS(2004)+ | <p>USE SYS(2004)+"\tutorial\customer.dbf" COPY TO test.txt TYPE DELIMITED FOR RECNO() < 5</p> | ||
<pre> infile=FOPEN( | <pre> infile=FOPEN("test.txt",10) && read-only, unbuffered | ||
IF infile | IF infile > 0 && file opened? | ||
SET SAFETY OFF & | SET SAFETY OFF && no warnings | ||
outfile=FCREATE( | outfile=FCREATE("test2.txt",0) && create read/write file | ||
IF outfile | IF outfile > 0 | ||
FOR F=1 TO FCOUNT() & | FOR F=1 TO FCOUNT() && loop through fields + | ||
=FSEEK(outfile,0,2) & | =FSEEK(outfile,0,2) && go to end of file | ||
=FWRITE(outfile,CHR(34)+FIELD(F)+CHR(34)+ ; | =FWRITE(outfile,CHR(34)+FIELD(F)+CHR(34)+ ; | ||
IIF(F=FCOUNT(),[],[,])) & | IIF(F=FCOUNT(),[],[,])) && write field names | ||
ENDFOR | ENDFOR | ||
=FWRITE(outfile,CHR(13)) & | =FWRITE(outfile,CHR(13)) && carriage return (CR) + | ||
DO WHILE NOT FEOF(infile) & | DO WHILE NOT FEOF(infile) && now get data from | ||
linein=FGETS(infile) & | linein=FGETS(infile) && the input file | ||
=FSEEK(outfile,0,2) & | =FSEEK(outfile,0,2) && point to end of file | ||
=FWRITE(outfile,linein+CHR(13))& | =FWRITE(outfile,linein+CHR(13))&& write data with CR terminator | ||
ENDDO | ENDDO | ||
=FCLOSE(outfile) & | =FCLOSE(outfile) && close output file | ||
ENDIF | ENDIF | ||
=FCLOSE(infile) & | =FCLOSE(infile) && close input file | ||
ENDIF | ENDIF | ||
USE & | USE && close the database | ||
NOTE: The plus sign ( | NOTE: The plus sign ("+") at the end of a line denotes a code block that | ||
is necessary only if saving the field names is necessary, such as when | is necessary only if saving the field names is necessary, such as when | ||
you are creating a Word Merge list. | you are creating a Word Merge list. |
Latest revision as of 12:25, 21 July 2020
FIX: COPY TO DELIMITED Creates File with No Carriage ReturnsID: Q110539 2.50b MACINTOSH kbusage kbtshoot The information in this article applies to: - Microsoft FoxPro for Macintosh, version 2.5b SYMPTOMSIn FoxPro for Windows and FoxPro for MS-DOS, the following commands create a delimited ASCII file, with each record terminated by a carriage return and linefeed (CR/LF) combination. In FoxPro for Macintosh, the same commands create a delimited ASCII file, with each record terminated by a linefeed only. USE customer COPY TO newfile TYPE DELIMITED Many programs, such as Microsoft Word for Macintosh, require that delimited records be terminated by a carriage return at the end of each record. This problem occurs regardless of the delimiter used; for example, the problem occurs whether the DELIMITED or DELIMITED WITH TAB clause is used. RESOLUTIONThere are two possible workarounds for this problem:
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in FoxPro 2.6a for Macintosh. Additional reference words: FoxMac 2.50b fixlist2.60a buglist2.50b line feed hard return soft return tshoot trouble-shoot KBCategory: kbusage kbtshoot KBSubcategory: Keywords : kbcode kbtshoot kbusage Version : 2.50b Platform : MACINTOSH Solution Type : kbfix |
Last Reviewed: May 21, 1998 |