Link to home
Start Free TrialLog in
Avatar of aubie8
aubie8

asked on

Export *.dbf and *.fpt memo info to a text file.

I can get the information from the *.dbf file exported into a text file from the command line in the foxpro 8.0 beta version.  The issue I have is trying to get the memo data into a text file so that I can then run an import with these text files into another system.

I can only find brief mentions of this and no real answers.  I have never used Foxpro before so am learning through the help files.  But I need this done fairly quickly, like by this Friday now.

if you need any more info, please feel free to contact me at aubie8@yahoo.com

Thanks!
Chris
Avatar of slink9
slink9

1000 points for this question?

handle=FCREATE('c:\download\jw5.txt')
   IF handle < 0
     WAIT WINDOW "Unable to create file"
     RETURN
   ENDIF
   USE c:\download\jw2
   SCAN
     *Numeric values must be converted to characters before
     *writing them to a text file.
     *The following line converts the number to a string
     =FWRITE(handle,ALLTRIM(pid)+",")
     =FWRITE(handle,ALLTRIM(sid)+",")
     =FWRITE(handle,ALLTRIM(con)+",")
     =FWRITE(handle,ALLTRIM(com)+",")
     =FWRITE(handle,ALLTRIM(ad1)+",")
     =FWRITE(handle,ALLTRIM(ad2)+",")
     =FWRITE(handle,ALLTRIM(cit)+",")
     =FWRITE(handle,ALLTRIM(sta)+",")
     =FWRITE(handle,ALLTRIM(zip)+",")
     =FWRITE(handle,ALLTRIM(cty)+",")
     =FWRITE(handle,ALLTRIM(tl1)+",")
     =FWRITE(handle,ALLTRIM(tl2)+",")
     =FWRITE(handle,ALLTRIM(us1)+",")
     =FWRITE(handle,ALLTRIM(us2)+",")
     =FWRITE(handle,ALLTRIM(us3)+",")
     =FWRITE(handle,ALLTRIM(us4)+",")
     =FWRITE(handle,ALLTRIM(us5)+",")
     =FWRITE(handle,ALLTRIM(us6)+",")
     =FWRITE(handle,ALLTRIM(us7)+",")
     *The following sends open quotes for the memo field
     =FWRITE(handle,CHR(34))
     x=MEMLINES(notepad)
     FOR i = 1 TO x
       =FWRITE(handle,MLINE(notepad,i))
       *The following line inserts a space before writing the next
       *line from the memo field
       =FWRITE(handle," ")
     ENDFOR
     *the following line adds close quotes and a delimiter
     *after the memo field
     =FWRITE(handle,CHR(34))
     *the following line uses FPUTS to end a record with a
     *carriage return and linefeed
     =FPUTS(handle,chr(13)+chr(12))
   ENDSCAN
   =FCLOSE(handle)
The easiest way to do this is to use CURSORTOXML() to output the DBF file, including memos; XML can handle memos with no problem.  XML can be imported either through COM automation of the XMLDOM or SAX XML parsers, or via the XML OLEDB driver programmatically; some database products such as SQL Server 2000 have native XML handlers; all you'd need to do is define a schema or XSLT to transform the XML data to an equivalentSQL Server table - this is discussed in detail in "Professional SQL Server Programming" by Robert Vieira, published by Wrox Press.
ASKER CERTIFIED SOLUTION
Avatar of CarlWarner
CarlWarner
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My answer was accepted in the other question that was posted.  I don't know what will be done with this one.
It doesn't matter to me one bit.
I think that Aubie wants this one deleted, because the indication in the other post was that this was accidental.  As far as I know, there has been no effort to get it deleted, though.
Avatar of aubie8

ASKER

this code on the site (which i searched first by the way but must not have been asking the correct search question) does exactly what i wanted.
Cool.  Thanks!!!