Microsoft KB Archive/110539: Difference between revisions
m (Text replacement - "<" to "<") |
m (Text replacement - "&" to "&") |
||
(One intermediate revision 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 "MODIFY FILE <filename | <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> | ||
Line 43: | Line 43: | ||
<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)+"\tutorial\customer.dbf" COPY TO test.txt TYPE DELIMITED FOR RECNO() < 5</p> | <p>USE SYS(2004)+"\tutorial\customer.dbf" COPY TO test.txt TYPE DELIMITED FOR RECNO() < 5</p> | ||
<pre> infile=FOPEN("test.txt",10) & | <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("test2.txt",0) & | 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 ("+") at the end of a line denotes a code block that | NOTE: The plus sign ("+") at the end of a line denotes a code block that |
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 |