Microsoft KB Archive/111913

= Creating Comma-Delimited File That Retains Trailing Space =

Article ID: 111913

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b

-



This article was previously published under Q111913



SUMMARY
When you are copying a FoxPro database to a comma-delimited file using the COPY TO TYPE DELIMITED command, the trailing blanks of each field are removed. Occasionally, the entire file, including any trailing blanks found in a field, needs to be copied to an ASCII file, but no options exist for the COPY TO command to accomplish this. However, you can use low-level file functions to transport the entire contents of every field from a database into a comma-delimited ASCII file.



MORE INFORMATION
The following code uses low-level file functions to read the CLIENTS.DBF sample database file and place the characters and trailing blanks of each field in a comma-delimited ASCII file named TEST.TXT: USE C:\Foxprow\Sample\Organize\dbfs\clients.dbf HFILE=FCREATE('c:\Test.txt') GO TOP SCAN =FPUTS(HFILE,Client_id+","+Company+","+Contact+","+Address+;  ","+City+","+State+","+Zip+","+Areacode+","+Phone+","+Extension;   +","+STR(startbal,8,2)+","+DTOC(Baldate)+Cuisine+","+STR(Type)+",";   +Notes) ENDSCAN =FCLOSE(HFILE) NOTE: By default, the FPUTS function expects character type data in the fields. Therefore, in order to use numeric and date fields, add the STR and DTOC functions to convert the respective fields to character type data. Adding additional parameters to the STR function preserves the decimal places in the numeric fields.

