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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export MEMO fields into a text file

Status
Not open for further replies.

bullfroggie

Technical User
May 8, 2000
1
AU
need to export two fields one being a MEMO which cannot export into plain text into text file<br>
 
There is no command that will export a memo field.&nbsp;&nbsp;You Will Have to write a program. For example:<br><br>Assuming you have to export the memofield to a Space Delimited File with a width of 75.<br><br>close data<br>set memowidth to 75<br>lnexportfile=fcreate(&quot;exportfile.txt&quot; , 0)<br>use dbf2export<br>scan all<br>&nbsp;&nbsp;&nbsp;scatter memvar<br>&nbsp;&nbsp;&nbsp;copy memo memofield to memotext.txt<br>&nbsp;&nbsp;&nbsp;lnmemotext = fopen(&quot;memotext.txt&quot; , 0 )&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;do while !feof(lnMemoText)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lcString = fgets(lnMemotext , 75)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= fput(lnExportFile , M.FieldOne+lcString)<br>&nbsp;&nbsp;&nbsp;enddo<br>&nbsp;&nbsp;&nbsp;=fclose(lnExportFile)<br>&nbsp;&nbsp;delete file memotext.txt<br>endscan<br><br>Warning,&nbsp;&nbsp;I wrote this as an example and did not test it. I Hope the syntax is correct. Alter it as needed<br> <p>David W. Grewe<br><a href=mailto:Dave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br>
 
There is another solution if the data in your memo field is no longer than 254 characters.<br>Create a temporary table (Temp) with a character field (Text) with a length of 254 characters then copy the data from your original table memo field to the temp table character field as in:<br><br>SELECT Original<br>SCAN<br>SELECT Temp<br>APPEND BLANK<br>REPLACE Text WITH Original.memofldname<br>ENDSCAN<br>SELECT Temp<br>COPY TO C:\TEMP\TEST.TXT ALL TYPE DELIMITED WITH &quot;,&quot;<br><br>Check COPY TO command in your language reference manual for options on record selection and other options<br>
 
Or an alternate:<br><br><FONT FACE=monospace>select myfield1, myfield2, left(mymemo,254) as mytext <br>into cursor temp<br><br>copy to test.txt delimited</font> <p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br>
 
With Visual FoxPro 6.0 it's very very simple!<br><br>sele MyTable<br>m.Text1 = alltrim(Field1)<br>m.Text2 = alltrim(Field2)<br>=strtofile(m.Text1 + m.Text2, &quot;c:\MyDirectory\myfile.txt&quot;)<br><br>and that's all! Do you understand?
 
Wow, some of these threads are good.&nbsp;&nbsp;I wonder if sometimes the original post-er even checks back when they don't acknowledges them.&nbsp;&nbsp;<br>Did anyone see Stephen Black's article on strings in the new CoDe magazine?&nbsp;&nbsp;VFP 6 is blazingly fast even working with a 3MB or so file like <u>War and Peace</u>.&nbsp;&nbsp;MS made significant improvements in 6<br>John Durbin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top