Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Sunday, November 26, 2006 6:57 AM
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.
All replies (12)
Monday, November 27, 2006 5:50 AM ✅Answered
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)
Monday, November 27, 2006 10:27 AM ✅Answered
>>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
Monday, November 27, 2006 10:53 AM ✅Answered
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?
Sunday, November 26, 2006 7:47 AM
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
Sunday, November 26, 2006 10:50 AM
>> 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.
Sunday, November 26, 2006 11:26 AM
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.
Monday, November 27, 2006 2:31 AM
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
Monday, November 27, 2006 2:33 AM
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.
Tuesday, March 5, 2019 7:37 AM
By far the easiest way, using Sql Server 2012:
Make a new query
select [NameOfField] from [your table] where [NameOfField] is not null;
select the column and copy
open notepad and paste it.
Hope it helps you
Tuesday, March 5, 2019 10:34 AM
Hi Ramon Baiges,
giving an answer to a 13 year old thread is by all means a bit questionable, and giving an answer (and proposing it as a solution) that doesn't even fit to the OP doesn't make sense in any way.
Honestly, someone who used a VFP table to store data won't install a SQL Server to get the output he needs. ;)
Gruss / Best regards
-Tom
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible,
you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011
Tuesday, March 5, 2019 11:29 AM
Agreed.
The answer could also have been about using a editbox in a grid column or bind the textbox to the expression LEFT(memofield,254), it's less probable to me output to text file was the intention by what was reported as the problem of seeing the word "memo" or "Memo", that happens in a grid.
But if the questioner doesn't come back with more details in that direction after seeing the question was interpreted different, there is really no need to revive such threads, even if you know such an answer, even in the interest of knowledge base, rather reask the question as new question.
The already picked solutions were solutions in the interpretation of the question as it's also valid.
Besides that, there is KB241424
Bye, Olaf.
Tuesday, March 5, 2019 2:35 PM
Agreed as well. Invoking a 13 years old thread with the most nonsense reply is not good. Wish there were also down voting as in StackOverFlow.
I wonder anyway, who in the world, even assuming many versions of MS SQL Server already installed (like me), would take this path and copy & paste the content to notepad? Why wouldn't he directly copy & paste from VFP table - if it were anywhere an "easy" path to take?
And calls it "by far the easiest" :) "Easy" is relative but to me this sounds the "worst", "hardest" way to follow.