Solved

Storing to a string variable from a Memo/Text field

Posted on 2001-08-01
4
251 Views
Last Modified: 2010-04-06
Hi Experts,

I have a memo/text field on an MSSQL 7 table.
I want to read this field and store whatever value here on a string variable declared on my application.
My problem is that after saving this value to my string variable, what is being stored is like this :

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}{\f1\fnil MS Sans Serif;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\lang1033\f0\fs16 MYTEXT
\par \f1
\par }

Is there any function or something, that I can use to remove all the RTF formattings and simply get the text itself?
So based on the sample above, I only wanted to store the value "MYTEXT" on my string variable and exclude the RTF formattings.

If anybody can show me how to do this without using any components but simply delphi coding thru functions or procedures, I'll appreciate it wholeheartedly.

TIA,
jrmn


0
Comment
Question by:jrmn
  • 2
4 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6343437
just set the plaintext property to true of an TRichEdit-Component

well, you will not need a component, maybe you will find a parser
0
 
LVL 4

Author Comment

by:jrmn
ID: 6343482
Hi kretzschmar,

Yup, from the Database, I'll get the value from this field and store it on a local string variable...not putting it first on a TRichEdit or any other components.
I think a parser is one if not the best solution to this. Can you suggest a function/procedure to do this kind of stuff?

jrmn
0
 
LVL 3

Expert Comment

by:rondi
ID: 6343751
Hi jrmn (Jermaine ?),

Parsing may prove difficult, as RTF formatting can get
pretty complex. Play around with MS Word and type some
text containing chars like {, ? & \ and save as RTF.
Sometimes text is enclosed in braces {}, and some chars
are escaped with backslashes. So it would appear one
actually needs to interpret the various RTF markups.

I think the quickest workaround would be to put an
hidden RichEdit control somewhere (or create it) and
set PlainText := False; set the text to the string variable, then set PlainText := True; and retrieve the
text.

rondi.
0
 
LVL 3

Accepted Solution

by:
rondi earned 50 total points
ID: 6343755
Hi jrmn (Jermaine ?),

Parsing may prove difficult, as RTF formatting can get
pretty complex. Play around with MS Word and type some
text containing chars like {, ? & \ and save as RTF.
Sometimes text is enclosed in braces {}, and some chars
are escaped with backslashes. So it would appear one
actually needs to interpret the various RTF markups.

I think the quickest workaround would be to put an
hidden RichEdit control somewhere (or create it) and
set PlainText := False; set the text to the string variable, then set PlainText := True; and retrieve the
text.

rondi.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now