« [Tip] A Calculation to round off time into quarters | Main | [Tip] How to let your solution know the client is headless »

August 05, 2005

[Tip] The trick for the use of returns in calculations used in an RTF_AREA

By Robert Ivens
ROCLASI Software Solutions

As you probably know Servoy comes with 2 rich format fields:
- HTML_AREA
- RTF_AREA

Which is great to use for emails, small letters and mailings.
And with the use of the %%merge code%% feature of Servoy it's a powerful combination.

Lets say you want to use an address-label field in your RTF_AREA. You create a calculation that has all the info in it.
Of course you want to put the address info into different lines so it's correct format.
Now if you want to use returns in calculations used as merge codes in that RTF_AREA then you have a challenge.
In a HTML_AREA you would simply use <BR> and you were done.
But in an RTF_AREA that doesn't work.
Just adding a return code (\r or \n or \r\n) doesn't work either.

So now what?

By taking a look at the RTF specification we see that they use a \par code for a return.
But using this doesn't show a return in Servoy's RTF_AREA. It doesn't show "\par" in the text either so I guess it is recognized as a RTF code.
But something seems to be missing.

After a little experimenting it turns out that you need to add an extra \r (the return code).

So use \par\r for a return in an RTF_AREA when used in a calculation that you use in a RTF_AREA.

| Posted by Robert Ivens on August 5, 2005 at 05:18 PM in Tips | Permalink

Comments

I always use '\par\n ' and this works perfect. One thing you don't mention Robert, which I experienced to be crucial after almost every formatting code within RFT is the space...

Good tip!!!

Posted by: Marcel Trapman | Aug 6, 2005 2:20:07 PM

Post a comment