convert memo field and contents to text file  
Author Message
espirit





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

Hi,

I have a table order.dbf in visual foxpro which contains of memo field. My table is as below:-

order_no order_date prdcode order_qty remark
B00000001 26/07/2006 2020173 10.0 memo

When I double click the memo I'll be able to see the details. Eg. order has been cancelled. I would like to convert all the table information including order has been cancelled to text format with a specific alignment. I'm beginner user of visual foxpro. Kindly advice how to do that. Thank you.




Visual FoxPro1  
 
 
chanmy8





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

Hi,
If your memo field value length not more than 255 characters, you can

SELECT order_no,order_date,prdcode,order_qty, LEFT(remark, 255) as remark ;
FROM mytable INTO CURSOR mycursor

COPY TO ...

HTH

 
 
AndyKr





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

>> I would like to convert all the table information including order has been cancelled to text format with a specific alignment. I'm beginner user of visual foxpro. Kindly advice how to do that. Thank you.

The easiest way to do this is to use a couple of functions. First you will need STRTOFILE() which will write a specified string out to a file on disk and the basic process will be to loop through the table and convert the data in each record into a string, then write that string out to the file.

Formatting will have to be handled by converting all data to character format (you can use TRANSFORM() to do that) and the memo field can be handled by using ALINES() to convert the content of the memo to an array (one row = one line in the memo field) Now you can add the memo field contents to your output string by looping through the array and adding CHR(13) + CHR(10) (carriage return + line feed) characters to restore the multi-line format.

You will also need to add CHR(13) + CHR(10) to each output line before you write them out to file.




 
 
CetinBasoz





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

It depends on contents of memo. Since in VFP a memo field can hold anything up to 2Gb you might want to do that with XML. Check CursorToXML. Another alternative is ADO. Or it might be as simple as a select that chanmy8 showed. In other words what you have in there and target receiver is important.
 
 
espirit





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

Hi HTH,

I did as above but I got an error msg string is too long to fit. Any more solution Appreciate your help. Thanks


 
 
espirit





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

Hi Andykr,

Sorry I don't really understand coz I'm just a beginner user of Visual Foxpro. Pls provide me with the code if you don't mind. Thank you.


 
 
Lakshminarayana





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

If the contents of memo field in all the record is less. use a report writer to make a report. then give the command

repo form <filename> to <ouputputfilename.txt> ascii

then u will get the contents of memo field in text file.

but if the contents of memo field is too big then it is very difficult to format them or make a dbf out of them.

regards

(Lakshminarayana)



 
 
AndyKr





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

>>Sorry I don't really understand coz I'm just a beginner user of Visual Foxpro

Then I am sorry, but I can't help you much. I cannot possibly write the code for you. 

I am not being mean, or unkind, but I simply don't know what your table structure is, the field names, what the format you want the output, or even what version of VFP you are using!

Here is the basic structure for a program of this type (using VFP 9.0), now go figure out how to make it do exactly what you need:

SELECT [table]
SCAN
  FOR
lnCnt = 1 TO FCOUNT()
    lcField =
FIELD( lnCnt )
   
IF TYPE( lcField ) = "M"
     
*** Memo Field
     
lnLines = ALINES( laLines, lcField, 1 )
     
lcOutStr = ""
     
FOR lnLCount = 1 TO lnLines
        lcOutStr = lcOutStr + laLines
[ lnLCount ] + CHR(13) + CHR(10)
      NEXT
    ELSE
     
*** Convert to character string
     
lcOutStr = TRANSFORM( &lcField )
    
ENDIF
   
STRTOFILE( lcOutStr, [file_name], 1 )
  NEXT
ENDSCAN

 



 
 
chanmy8





PostPosted: Visual FoxPro General, convert memo field and contents to text file Top

Hi,
Sorry to inform that, I tested the maximum length of characters field is 254. And I didn't get any error message even I specify 256. In fact, VFP truncated the field to be 254 chars.

Which VFP version are you using