Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to Text file

1962dez

Programmer
Nov 20, 2008
6
CV
Good afternoon,
I need to create a text file like the one attached, with data from a cursor. What command should I use to put the data in the text file and how to respect the columns of each piece of information?
I appreciate any help.
 

Attachments

  • ERP0605C.txt
    136.5 KB · Views: 15
copy to ERP0605C.txt sdf

This is just a simple fixed field text file. If you only want certain fields you can include the "FIELDS ..." switch.
 
Viewing this without automatic line breaks, I see a long record structure which is of the type SDF. At least from line 6 onwards. The clues are defined column widths without delimiters, neither tabs nor commas.

To give an example of producing such a line here's the output of a cursor with 3 char(10) fields:
Code:
Create Cursor crsExport (c1 C(10), c2 c(10), c3 c(10))
Insert into crsExport values ("aaaaaaaaaa","bbbbbbbbbb","cccccccccc")
Insert into crsExport values ("dddddddddd","eeeeeeeeee","ffffffffff")
COPY TO demo.sdf TYPE SDF
Modify File demo.sdf
You can also give it the file extension txt, VFP is not needing the file extension but the TYPE SDF option is outputting the way you need. Ther are still a lot of details to fiddle with, when it comes to fields of other types like numbers, dates, etc., but you get the gist, all it needs is mainly a COPY TO... TYPE SDF.
 

Part and Inventory Search

Sponsor

Back
Top