WPCubed Product Support

Replace tokens with special attributes like Bold or Colour

Hi to all.

I am VERY new to WP Tools... I hope someone can help.

Delphi 7 is my dev env.

I am replacing another RichText component with WPT. I have a set of very non-standard tokens that I have to replace after opening a file and before display.

The Tokens are lead-in and lead-out. For example: ~FGR~ Hello World ~FGE~ is ot be displayed as " Hello World " in Red font colour.

Q.: Is that a simple method with WPT similar to ReplaceTokens that will allow me to:
(i) process the token replace one at a time,
(ii) return as SelText all characters between the tokens and then
(iii) allow me to change the attributes for the selected SelText

One other Q: How would I change he attribute of SelText to display as Superscript / Subscript?

TIA

Zane

#1 ♥ 0
4k Views 2 users read 2 min

There being no challenge taker's or suggestions...

I tried using SynEdit but found it all together too much hard work.

I have implemented the solution by coding the solution using TWPCustomRtfEdit.Finder and TWPCustomRtfEdit.SelectedTextAttr.

Surprisingly (to me) the routine speed is MUCH faster than a similar process implemented using InfoPower RichText components.

Regards

Zane

#2 ♥ 0
support

Hi,

The solution with Finder and TWPCustomRtfEdit.SelectedTextAttr I would also have suggested.

Note you can use a wildcard to modify all tokens at once

Finder.WildCard := '*'
while Finder.Next('~*~') do
begin
if FoundText = ... then FoundText := ...
FoundAttr.SetColor( .. )
end;

Please also note the method ReplaceTokens, text such as ~FGR~ could be converted into mail merge fields that way. ReplaceTokens also uses the finder internally.

#3 ♥ 0
This category is archived. No new posts are possible.