Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Visual Foxpro access retrieve data memo fields

Posted on 2011-09-15
3
2,503 Views
Last Modified: 2012-05-12
Normally I never use in my applications memo fields. Always had some issues to use them, namely because it was not clear to me the way i should write and read data in these containers.
I would like to know the way I should write and retireve data from Visual Foxpro memo fields
and what kind of data I can insert into them.
Thanks in advance for you help
0
Comment
Question by:luciliacoelho
3 Comments
 
LVL 27

Accepted Solution

by:
CaptainCyril earned 250 total points
ID: 36547224
I use memo fields to write lengthy values (more than 254 chars).
I also use memo fields to store Unicode text, RTF text and properties (ini files).
I used to store word documents, pictures, MS-Charts in memo fields only to display them in FRX Reports but now I store them outside the table and reference them from inside the table and the filenames are store in the memo fields.

To normally use memo fields
REPLACE table.memofield WITH cLongText
Thisform.editbox.Value = table.memofield

To store an object instance in a memo field use APPEND MEMO
APPEND MEMO notes FROM test.txt

To store General Fields: Pictures, Music Files, Charts, ...
CREATE TABLE MyGenTbl (mygenfield G)
APPEND BLANK  && Add a blank record
APPEND GENERAL mygenfield FROM C:\EXCEL\BOOK1.XLS CLASS EXCELCHART

If you are using some DBF readers or database connections, you might have problems reading and writing from memo fields.

If you use COPY TO sheet.xls TYPE XLS it will not export memo contents. You will have to do that via Excel Automation.
0
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 250 total points
ID: 36548965
A normal memo is like a larger textfield, so you read and write to it like to a normal char field.
Cyril already discussed some other commands special to memos, but you don't need APPEND MEMO, it's just another possibility. You could also read in a file via FILETOSTR() and then store that as you store a value coming elsewehere into a char field. From that perspective it's as easy to use and maintain as any char field.

The difference is in how VFP displays memo contents. Simply use an editbox instead of any other control, and you get the memo content directly displayed instead of "memo" or "Memo", which is what foxpro displays in a textbox or a default grid column.

Another difference Cyril already told is the handling of memos in COPY TO and also EXPORT.

And yet another difference is, you can't GROUP BY memo fields in SQL, and you can't also SELECT DISTINCT with a memo field in the field list. I can only guess the machnisms doing these kind of sql operations need same size values and VFP would need to pad all memos to the same maximum length for that, which was considered as a bad thing performancee wise, so instead this was handled as forbidden, there may also be a size limit as the one for normal char fields.

There are some special memo field types, if talking about memo as a term for all field types stored in an fpt file, namely blob and general field. I'd avoid general in general, and blob is for storage of files, a special feature is you can set an image control pictureVal property to a blob field and let it display as picture, valid for images stored in blob, that foxpro can display, but it's easier and better to not put files into tables anyway.

Additional to that there is memo (binary), but that is also a form of field modification you have for other field types, eg char (binary). This simply means storage is not for a certain codepage and putting in values does neither check any codepage nor make any conversion, data is stored 1:1

Memo is convenient for larger portions of text, especially multi line. I mainly use it for comment/remark fields with less important data, that nevertheless will perhaps help to store some instructions of other short text passages.
I also sometimes use it for paths, as those can get longer than 254 chars. But I mainly use it for larger texts, not even for rtf, which is not wrong, but plain text without more formatting attributes is okay for my user base.

Bye, Olaf.
0
 

Author Comment

by:luciliacoelho
ID: 36553334
Thank you Olaf and Ciryl for your information. i'm going to try your  helpful advises
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question