In Line....

----- Original Message ----- From: "Lawrence Lustig" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Thursday, July 16, 2009 12:54 PM
Subject: [RBASE-L] - Re: VarChar Data and RTF



<<
The VarChar doesn't know crap from shinola as far as what it contains.  It
contains VARying length of CHARacters and that's all.  So SRPL and other
text manipulation functions work just fine.



Unfortunately, they will not work reliably on RTF encoded text. The reason is that the text that you may THINK is written as "[FNAME]" (because that's what it looks like) is not represented that way in the encode text:

1. It could have RTF encoding in the middle of it.

It could have, but it looks like Mark is the creator of the text and the examples were placeholders of his own creation and unlikely to have formatting applied by a user. None of the RBase RTF components allow for the bolding of a single character or word in the middle of text as you know.

2. It could have escaped characters that don't look like what you think they look like. For instance, I'm not sure if the square brackets are escaped in RTF text, but plenty of characters are.

In otherwords, the RTF encoded text for "[FNAME]" could read "\[FN{rtf blah blah}AME\]". It's impossible to predict what will appear in the text in advance because it can depend on editing decisions made by the user in the RTF control (applying and removing styles, for instance).


 as above.

If the RTF text you want to operate on is fixed (entered by you, once, and stored in a table without change) and if you take the time to examine the resulting text and specifically code your SRPLs to whatever you find in the text, you could make this work. But if you later change that text using an RTF control or allow the user to edit it, you'd have to recode your SRPLs.


In his instance, it looks like there is no user editing using the RBBE. Just concantenating text and performing SRPL on the placeholders, unless Mark is going to reveal differently, then all bets are off.

To check how hacked up your text is, simply BROWSE the VARCHAR column that contains the RTF encoded text. You will be shocked at what's going on in there.

The only reliable way I know of performing these kinds of RTF replacements is to instantiate an RTF control and use the API of that control to search and replace. This is not directly supported by R:Base (at least, not at this time) although I imagine it can be done using Windows messaging.

The takeaway? Programmatic operation on RTF text is not something for the faint of heart. Any solution relying on operating on the encoded text is likely to be a hack that will come apart at the first opportunity for failure. If you need to do it, you'll want to find a way to use the API.
--
Larry




Reply via email to